Search code examples
node.jsforever

Forever run `npm start` can't find '/package.json'


I'm trying to run npm start and keep it running forever. So I executed the following command forever -c "npm start" /home/deploy/frontend where the path provided leads to my sourcefolder of my Angular 2 application.

When I run npm start in that folder, a lite-server starts and everything works fine. With this command however, it's trying to access /package.json, but since I'm running on Linux, this will not result into ..../frontend/package.json but just /package.json.

Is there some way of configuring forever to run the scripts from my /home/deploy/frontend/package.json?

The logs (just snipped out 1 out of 3 attempts):

:    /home/deploy/frontend:28134 - error: Script restart attempt #3
data:    /home/deploy/frontend:28134 - npm ERR! Linux 4.4.0-72-generic
data:    /home/deploy/frontend:28134 - npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start" "/home/deploy/frontend"
data:    /home/deploy/frontend:28134 - npm ERR! node v7.10.0
data:    /home/deploy/frontend:28134 - npm ERR! npm  v4.2.0
data:    /home/deploy/frontend:28134 - npm ERR! path /package.json
data:    /home/deploy/frontend:28134 - npm ERR! code ENOENT
data:    /home/deploy/frontend:28134 - npm ERR! errno -2
data:    /home/deploy/frontend:28134 - npm ERR! syscall open
data:    /home/deploy/frontend:28134 - npm ERR! enoent ENOENT: no such file or directory, open '/package.json'
data:    /home/deploy/frontend:28134 - npm ERR! enoent ENOENT: no such file or directory, open '/package.json'
data:    /home/deploy/frontend:28134 - npm ERR! enoent This is most likely not a problem with npm itself
data:    /home/deploy/frontend:28134 - npm ERR! enoent and is related to npm not being able to find a file.
data:    /home/deploy/frontend:28134 - npm ERR! enoent
data:    /home/deploy/frontend:28134 - npm ERR! Please include the following file with any support request:
data:    /home/deploy/frontend:28134 - npm ERR!     /root/.npm/_logs/2017-06-19T08_39_29_496Z-debug.log
data:    /home/deploy/frontend:28134 - error: Forever detected script exited with code: 254

Solution

  • Try to execute:

    forever start -c "npm start" /home/deploy/frontend/
    

    or, if that fails, from your application directory:

    forever start -c "npm start" ./