In our CentOS server, the env variable NODE_OPTIONS
was set to a wrong value. I checked some possible files such as /etc/environment, /etc/profile, but no luck. I also tried to grep it from /etc/, still no luck. This makes me upset.
I even tried this: https://unix.stackexchange.com/a/154971/92712
Surprised to find that there's no such variable in the output. But it is in
printenv NODE_OPTIONS
set | grep NODE_OPTIONS
echo $NODE_OPTIONS
(shell is bash)
Is there any way to get in which file the this NODE_OPTIONS comes from?
More info:
$ node -v
node: invalid value for NODE_OPTIONS (unterminated string)
$ echo $NODE_OPTIONS
--max-old-space-size=5120"
$ cat /etc/environment
export NODE_OPTIONS="--max-old-space-size=5120"
Update:
Thanks @ilkkachu
$ declare -p NODE_OPTIONS
declare -x NODE_OPTIONS="--max-old-space-size=5120\" "
update 2: The extra double quotation appears in env
output too:
$ env
NODE_OPTIONS=--max-old-space-size=5120"
update 3: Thanks @Johan Myréen
$ od -c /etc/environment
0000000 \n e x p o r t N O D E _ O P T
0000020 I O N S = " - - m a x - o l d -
0000040 s p a c e - s i z e = 5 1 2 0 "
0000060 # i n c r e a s e t o 5 g
0000100 b \n \n
0000103
-l
option, still no luck. – Nick Aug 11 '21 at 11:51echo $NODE_OPTIONS
, but no leading one, is that right? You could also usedeclare -p NODE_OPTIONS
to have Bash print it in an unambiguous form. – ilkkachu Aug 11 '21 at 12:07/etc/environment
should contain simpleNAME=VALUE
pairs. Remove theexport
. (I don't think this solves your problem, though.) – Johan Myréen Aug 11 '21 at 12:28od -c /etc/environment
. – Johan Myréen Aug 11 '21 at 13:19od
command output to the update. Is that look good? – Nick Aug 11 '21 at 13:24/etc/environment
really should contain onlyNAME=VALUE
pairs and nothing else. Noexport
and no comments. The file is not parsed by a shell. – Johan Myréen Aug 11 '21 at 13:28#
character, and it will solve your problem. While you are at it, remove theexport
too, since it should not be there. – Johan Myréen Aug 11 '21 at 13:48od
output includes a comment that's not there in thecat
output. – ilkkachu Aug 11 '21 at 19:32cat
output at first, because I thought it was not helpful to solve the problem. It turns out that I was wrong. – Nick Aug 12 '21 at 01:24/etc/environment
it looks like it works line-by-line, but esp. with code, seeing the whole file is important just so people can see that there's no surprises in the part left out. Except in the cases where that results in hundreds of lines which no-one wants to wade through. Finding the line there is one of the problems of debugging. – ilkkachu Aug 12 '21 at 07:30