我正在开发一个应用程序,它使用VueJS显示视图,ExpressJS充当服务器。
到目前为止在本地工作正常,但在Heroku上成功部署后,它不会加载应用程序并使dyno崩溃。
我的文件夹结构是这样的:
这是Heroku引用构建整个应用程序的package.json:
{
"name": "my-app",
"version": "0.1.0",
"scripts": {
"postinstall": "npm install --prefix server && npm install --prefix client"
}
}
服务器的package.json:
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "./src/app.js",
"scripts": {
"start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run lint && node'",
"lint": "./node_modules/.bin/eslint **/*.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.2",
"cors": "^2.8.4",
"eslint": "^4.12.1",
"express": "^4.16.2",
"morgan": "^1.9.0",
"nodemon": "^1.12.5",
"pg": "^7.4.0",
"sequelize": "^4.27.0"
},
"devDependencies": {
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1"
}
}
我检查了日志,问题出现在eslint库中,Heroku在我的项目中找不到。关于如何解决这个问题的任何想法?
2017-12-08T14:55:35.408127+00:00 app[web.1]: Cannot find module 'eslint-config-standard'
2017-12-08T14:55:35.408145+00:00 app[web.1]: Referenced from: /app/server/.eslintrc.js
2017-12-08T14:55:35.408945+00:00 app[web.1]: Error: Cannot find module 'eslint-config-standard'
2017-12-08T14:55:35.408947+00:00 app[web.1]: Referenced from: /app/server/.eslintrc.js
2017-12-08T14:55:35.408948+00:00 app[web.1]: at ModuleResolver.resolve (/app/server/node_modules/eslint/lib/util/module-resolver.js:74:19)
2017-12-08T14:55:35.408949+00:00 app[web.1]: at resolve (/app/server/node_modules/eslint/lib/config/config-file.js:471:25)
2017-12-08T14:55:35.408950+00:00 app[web.1]: at load (/app/server/node_modules/eslint/lib/config/config-file.js:542:26)
2017-12-08T14:55:35.408951+00:00 app[web.1]: at configExtends.reduceRight (/app/server/node_modules/eslint/lib/config/config-file.js:421:36)
2017-12-08T14:55:35.408951+00:00 app[web.1]: at Array.reduceRight (<anonymous>)
2017-12-08T14:55:35.408952+00:00 app[web.1]: at applyExtends (/app/server/node_modules/eslint/lib/config/config-file.js:403:28)
2017-12-08T14:55:35.408953+00:00 app[web.1]: at loadFromDisk (/app/server/node_modules/eslint/lib/config/config-file.js:514:22)
2017-12-08T14:55:35.408953+00:00 app[web.1]: at Object.load (/app/server/node_modules/eslint/lib/config/config-file.js:550:20)
2017-12-08T14:55:35.408954+00:00 app[web.1]: at Config.getLocalConfigHierarchy (/app/server/node_modules/eslint/lib/config.js:228:44)
2017-12-08T14:55:35.408955+00:00 app[web.1]: at Config.getConfigHierarchy (/app/server/node_modules/eslint/lib/config.js:180:43)
2017-12-08T14:55:35.464317+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-12-08T14:55:35.464681+00:00 app[web.1]: npm ERR! errno 1
2017-12-08T14:55:35.466080+00:00 app[web.1]: npm ERR! server@1.0.0 lint: `eslint **/*.js`
2017-12-08T14:55:35.466205+00:00 app[web.1]: npm ERR! Exit status 1
2017-12-08T14:55:35.466413+00:00 app[web.1]: npm ERR!
2017-12-08T14:55:35.466555+00:00 app[web.1]: npm ERR! Failed at the server@1.0.0 lint script.
2017-12-08T14:55:35.466726+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-12-08T14:55:35.491352+00:00 app[web.1]:
2017-12-08T14:55:35.491535+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-12-08T14:55:35.491648+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-12-08T14_55_35_468Z-debug.log
2017-12-08T14:55:35.506231+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...
2017-12-08T14:56:08.700333+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/status" host=babbelbord.herokuapp.com request_id=f86a8552-14b5-477c-b79d-d575ad30bffa fwd="84.81.81.130" dyno= connect= service= status=503 bytes= protocol=https
答案 0 :(得分:5)
感谢Heroku的支持,找到了答案。问题是我的依赖项是在package.json文件的devDependencies
中定义的,而它们应该在dependencies
中声明,以便Heroku正常工作。
答案 1 :(得分:0)
您似乎是在eslint-config-standard
内引用/app/server/.eslintrc.js
,但是您的package.json没有任何依赖项。
您将需要运行npm install eslint-config-standard --save
,这将在您的package.json中创建一个依赖项。然后你应该保存以提交更改并再次部署到heroku。
因为你没有在package.json中声明你的依赖,你的dyno将不知道安装它。我怀疑您只是忘记将--save
标记添加到原始npm install
,因此它只会安装到您的node_modules
文件夹中而不会在package.json
中输入。< / p>