我正在尝试运行npm start
并让它永远运行。所以我执行了以下命令forever -c "npm start" /home/deploy/frontend
,其中提供的路径指向我的Angular 2应用程序的源文件夹。
当我在该文件夹中运行npm start
时,一个lite-server启动,一切正常。但是,使用此命令,它正在尝试访问/package.json
,但由于我在Linux上运行,因此不会导致..../frontend/package.json
,而只会导致/package.json
。
是否有某种方法可以配置forever
来运行/home/deploy/frontend/package.json
中的脚本?
日志(只扫了3次尝试中的1次):
: /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
答案 0 :(得分:3)
尝试执行:
forever start -c "npm start" /home/deploy/frontend/
或者,如果失败,请从您的应用程序目录:
forever start -c "npm start" ./
答案 1 :(得分:0)
当您在具有相同项目或程序包名称的文件夹中创建项目时,会出现问题。尝试在其他文件夹中创建项目,以便在构建时React框架可以查找package.json文件