realm-js: node: command not found
PhaseScriptExecution Download\ Core /Users/me/Library/Developer/Xcode/DerivedData/Ology-dyfbenzvbbghgeebclxmorqgivwr/Build/Intermediates.noindex/RealmJS.build/Debug-iphonesimulator/RealmJS.build/Script-F63FF2C51C12462600B3B8E0.sh
cd /Users/me/project/node_modules/realm/src
/bin/sh -c /Users/me/Library/Developer/Xcode/DerivedData/Ology-dyfbenzvbbghgeebclxmorqgivwr/Build/Intermediates.noindex/RealmJS.build/Debug-iphonesimulator/RealmJS.build/Script-F63FF2C51C12462600B3B8E0.sh
/Users/me/Library/Developer/Xcode/DerivedData/Ology-dyfbenzvbbghgeebclxmorqgivwr/Build/Intermediates.noindex/RealmJS.build/Debug-iphonesimulator/RealmJS.build/Script-F63FF2C51C12462600B3B8E0.sh:
line 2: node: command not found
Command /bin/sh failed with exit code 127
I get this error on a current project that I installed on a new machine.
Node was installed through nvm react-native 0.49.5 realm-js 2.0.2 Mac OS High Sierra nvm ls
-> v8.8.1
default -> 8.8.1 (-> v8.8.1)
node -> stable (-> v8.8.1) (default)
stable -> 8.8 (-> v8.8.1) (default)
iojs -> N/A (default)
lts/* -> lts/boron (-> N/A)
lts/argon -> v4.8.5 (-> N/A)
lts/boron -> v6.11.5 (-> N/A)
When I run node on the command line, it works normally.
Any ideas?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 18 (8 by maintainers)
Oh, yeah sorry that’s probably because when you run
/bin/shfrom your terminal it’s picking up thePATHfrom the parent shell, which allows node to work.Different approach then, try (from your usual terminal where node is working):
ln -s $(which node) /usr/local/bin/nodeThat should put a symlink to node somewhere in the
PATHthatshuses. If it already exists, I’m stumped.On OSX, I installed node@8 with homebrew which points to
/usr/local/opt/node@8/bin/nodeinstead of/usr/local/bin/node.So
ln -s $(which node) /usr/local/bin/nodeas written by @rh389 does the trick!nvm is usually before
/usr/local/bininPATHso if you change node version with nvm in your usual shell that should work fine, but Xcode will continue to use the symlinked (old) version. Running the above command again would bring Xcode back into line. AFAIK there’s no system/user default to point to because nvm is designed to be local to each shell. You could install node system-wide alongside nvm though if you wanted to have a “primary” version.Any update on this?
ln -s $(which node) /usr/local/bin/nodeis bad, because it fixes the node version on/usr/local/bin/node.When using NVM, the goal is that the version of the node is not fixed.
That’ll be the problem then - nvm is per-shell so even though node is on the path from your usual shell, xcode (which just runs things under
/bin/sh) can’t see it. You can runecho $PATHfrom each shell to confirm that your usual shell has a node path (usually) under~/.nvm/versionsthat/bin/shdoesn’t show.I’d recommend installing nvm into
/bin/shand setting its default node version to be the same as you’re using elsewhere.