0


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.

Ahmed Commando
  • 723
  • 2
  • 7
  • 23

2 Answers2

1

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
rsp
  • 107,747
  • 29
  • 201
  • 177
  • yes in that work it works with the terminal but when i launch it from a scipt it doesnt work – Ahmed Commando Dec 01 '16 at 16:11
  • i created a service in /etc/init/ to launch the service with that path, i did it before and it worked fine, but now i get this error. it seems like npm start doesnt look for the right path. – Ahmed Commando Dec 01 '16 at 16:15
  • what i did to fix it is creating a new user and change the project folder under the new user home directory and it worked. So i still don't know why it happened. but your solution is good too, i tested it and it worked too. Thank you. – Ahmed Commando Dec 01 '16 at 17:28
0

When you use npm start you don't need to specify the file path. You have to be on the directory of your project cd project_directory and there run npm start. Also make sure that in your package json, you have specified in the "start" property, the file to start.

Alee
  • 740
  • 7
  • 19