Ahmed Commando Ahmed Commando - 5 days ago 4
Node.js Question

npm start run in wrong path



First of all i'm using Ubuntu 14.04, and i create a node.js project under

/home/user/project_folder
.

When i type
npm start /home/user/project_folder/
, i get this error:


npm ERR! node v4.6.1

npm ERR! npm v4.0.2

npm ERR! path /home/user/package.json

npm ERR! code ENOENT

npm ERR! errno -2

no such file or dir..


Am'i doing it wrong? did i forget something?

Thank you.

rsp rsp
Answer

npm doesn't take the path as an argument.

What you want is:

cd /home/user/project_folder && npm start

You can put it in a script, e.g. save this as /home/user/project_folder/run.sh:

#!/bin/sh
cd /home/user/project_folder && npm start

Change permissions with:

chmod a+x /home/user/project_folder/run.sh

And run it with just:

/home/user/project_folder/run.sh

Or without changing permissions:

sh /home/user/project_folder/run.sh