如何在pm2中部署feathersjs应用程序?

时间:2017-09-20 07:15:57

标签: javascript node.js ubuntu pm2 feathersjs

我正在使用feathersjs框架来开发nodejs应用程序,我正在尝试在pm2中实现它并且它无法正常工作。

drwxr-xr-x   8 root root   4096 Sep 20 06:45 ./
drwx------  12 root root   4096 Sep 20 06:48 ../
drwxr-xr-x   2 root root   4096 Sep 20 06:48 config/
-rw-r--r--   1 root root    214 Sep 20 06:44 .editorconfig
-rw-r--r--   1 root root    334 Sep 20 06:44 .eslintrc.json
drwxr-xr-x   8 root root   4096 Sep 20 07:02 .git/
-rw-r--r--   1 root root    884 Sep 20 06:44 .gitignore
-rw-r--r--   1 root root   1076 Sep 20 06:44 LICENSE
drwxr-xr-x 391 root root  16384 Sep 20 06:45 node_modules/
-rw-r--r--   1 root root    594 Sep 20 06:44 .npmignore
-rw-r--r--   1 root root   1716 Sep 20 06:44 package.json
-rw-r--r--   1 root root 119897 Sep 20 06:44 package-lock.json
drwxr-xr-x   2 root root   4096 Sep 20 06:44 public/
-rw-r--r--   1 root root     84 Sep 20 06:44 README.md
drwxr-xr-x   6 root root   4096 Sep 20 06:48 src/
drwxr-xr-x   3 root root   4096 Sep 20 06:44 test/
-rw-r--r--   1 root root  84576 Sep 20 06:44 yarn.lock

这是我的应用程序文件夹结构:

我正在按照以下方式运行

$ cd src
$ pm2 start app.js

我收到了以下错误:

0|app      | TypeError: Path must be a string. Received undefined
0|app      |     at assertPath (path.js:7:11)
0|app      |     at Object.join (path.js:1218:7)
0|app      |     at Object.<anonymous> (/home/limitless/Documents/projects/work/iRouteApp/src/app.js:36:22)
0|app      |     at Module._compile (module.js:570:32)
0|app      |     at Object.Module._extensions..js (module.js:579:10)
0|app      |     at Module.load (module.js:487:32)
0|app      |     at tryModuleLoad (module.js:446:12)
0|app      |     at Function.Module._load (module.js:438:3)
0|app      |     at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:70:21)
0|app      |     at Module._compile (module.js:570:32)
0|app      |     at Object.Module._extensions..js (module.js:579:10)
0|app      |     at Module.load (module.js:487:32)
0|app      |     at tryModuleLoad (module.js:446:12)
0|app      |     at Function.Module._load (module.js:438:3)
0|app      |     at Module.runMain (module.js:604:10)
0|app      |     at run (bootstrap_node.js:389:7)
0|app      |     at startup (bootstrap_node.js:149:9)
0|app      |     at bootstrap_node.js:502:3
PM2        | App [app] with id [0] and pid [14134], exited with code [1] via signal [SIGINT]
PM2        | Starting execution sequence in -fork mode- for app name:app id:0
PM2        | App name:app id:0 online
0|app      | WARNING: NODE_APP_INSTANCE value of '0' did not match any instance config file names.
0|app      | WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
0|app      | WARNING: No configurations found in configuration directory:/home/limitless/Documents/projects/work/iRouteApp/src/config
0|app      | WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.

2 个答案:

答案 0 :(得分:3)

app.js不是feathersjs样板中的根文件。

它应该是index.js

所以只需使用pm2 start src/

答案 1 :(得分:0)

当找不到适合您环境的配置文件(config/default.jsonconfig/production.json等)时,例如在Dockerfile中,如果配置文件未正确复制,也会出现此错误。