+3 votes
1 view
in Blockchain by (21.1k points)

The code I am running is as follows:

npm install -g ethereumjs-testrpc

/usr/local/bin/testrpc -> /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js

The error is as follows:

sh: node: command not found

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/ethereumjs-testrpc/node_modules/fsevents):

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node install`

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: spawn ENOENT

npm ERR! file sh

npm ERR! code ELIFECYCLE

npm ERR! errno ENOENT

npm ERR! syscall spawn

npm ERR! [email protected] postinstall: `node lib/post_install.js`

npm ERR! spawn ENOENT

npm ERR! 

npm ERR! Failed at the [email protected] postinstall script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

2 Answers

+4 votes
by (46.3k points)

The first step is to install nodejs and npm:

For Node.js: 

sudo apt-get update

sudo apt-get install nodejs

For npm:

sudo apt-get install npm

by (24.5k points)
After these commands, To check whether node js is installed or not you could use:

$ nodejs -v
by (18.3k points)
Worked for me readily! thanks
by (32.8k points)
It is the easiest way to install nodejs and npm.
Thanks!
by (36.9k points)
I think there was some problem with the path. Setting the path solved the issue. Thank you
by (8.1k points)
Thank you. It worked for me.
by (29.8k points)
I installed the mentioned applications and also mentioned the right path. Still getting the same error.
0 votes
by (76.5k points)

The command not found error you are getting because your PATH does not include the location of the node executable.

So you can use "/usr/local/bin/node" to run node.

Another thing you can add that location to your path by running the following command to add a single line to your bashrc file:

echo 'export PATH=$PATH:/usr/local/bin' >> $HOME/.bashrc

by (27.7k points)
Thanks worked like a charm!!
by (19.9k points)
If u install via nvm then node won' be there.
by (42.2k points)
The path was the problem, this solved the issue
...