第一次将此应用程序推送到heroku(并且第一次执行NodeJS API),并且当应用程序尝试启动时,我在heroku的日志中收到此错误。它在开发中工作正常 - 我错过了什么?
我有一个文件:config/prod.json
在package.json
中"scripts": {
"start": "export NODE_ENV=prod && nodemon ./index.js",
"windev": "set NODE_ENV=dev && nodemon ./index.js",
"dev": "export NODE_ENV=dev && nodemon ./index.js",
"prod": "export NODE_ENV=prod && nodemon ./index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
完整输出:
2018-01-05T21:40:37.628592+00:00 app[web.1]: > export NODE_ENV=prod && nodemon ./index.js
2018-01-05T21:40:37.628593+00:00 app[web.1]:
2018-01-05T21:40:39.610679+00:00 app[web.1]: [nodemon] 1.12.5
2018-01-05T21:40:39.620087+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2018-01-05T21:40:39.620443+00:00 app[web.1]: [nodemon] watching: *.*
2018-01-05T21:40:39.621169+00:00 app[web.1]: [nodemon] starting `node ./index.js`
2018-01-05T21:40:42.769518+00:00 app[web.1]: module.js:540
2018-01-05T21:40:42.769527+00:00 app[web.1]: throw err;
2018-01-05T21:40:42.769528+00:00 app[web.1]: ^
2018-01-05T21:40:42.769528+00:00 app[web.1]:
2018-01-05T21:40:42.769529+00:00 app[web.1]: Error: Cannot find module './prod.json'
2018-01-05T21:40:42.769555+00:00 app[web.1]: at Module.require (module.js:587:17)
2018-01-05T21:40:42.769553+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:538:15)
2018-01-05T21:40:42.769554+00:00 app[web.1]: at Function.Module._load (module.js:468:25)
2018-01-05T21:40:42.769559+00:00 app[web.1]: at Module._compile (module.js:643:30)
2018-01-05T21:40:42.769556+00:00 app[web.1]: at Object.<anonymous> (/app/config/config.js:2:18)
2018-01-05T21:40:42.769556+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-01-05T21:40:42.769560+00:00 app[web.1]: at Module.load (module.js:556:32)
2018-01-05T21:40:42.769560+00:00 app[web.1]: at Object.Module._extensions..js (module.js:654:10)
2018-01-05T21:40:42.769561+00:00 app[web.1]: at Function.Module._load (module.js:491:3)
2018-01-05T21:40:42.769561+00:00 app[web.1]: at tryModuleLoad (module.js:499:12)
2018-01-05T21:40:42.769563+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-01-05T21:40:42.769563+00:00 app[web.1]: at Module.require (module.js:587:17)
2018-01-05T21:40:42.769564+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:6:16)
2018-01-05T21:40:42.769565+00:00 app[web.1]: at Module._compile (module.js:643:30)
2018-01-05T21:40:42.769565+00:00 app[web.1]: at Object.Module._extensions..js (module.js:654:10)
2018-01-05T21:40:42.769566+00:00 app[web.1]: at Module.load (module.js:556:32)
2018-01-05T21:40:42.769568+00:00 app[web.1]: at tryModuleLoad (module.js:499:12)
2018-01-05T21:40:42.769569+00:00 app[web.1]: at Function.Module._load (module.js:491:3)
2018-01-05T21:40:42.769570+00:00 app[web.1]: at Function.Module.runMain (module.js:684:10)
2018-01-05T21:40:42.769571+00:00 app[web.1]: at startup (bootstrap_node.js:187:16)
2018-01-05T21:40:42.769572+00:00 app[web.1]: at bootstrap_node.js:608:3
2018-01-05T21:40:42.827358+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...