Express Heroku应用程序因eslint错误导入而崩溃

Express Heroku应用程序因eslint错误导入而崩溃,express,heroku,npm,eslint,package.json,Express,Heroku,Npm,Eslint,Package.json,我正在开发一个应用程序,它使用VueJS显示视图和充当服务器的ExpressJS 到目前为止,它在本地运行良好,但在Heroku上成功部署后,它不会加载应用程序并使dyno崩溃 我的文件夹结构如下所示: 项目根 客户 客户端的package.json 服务器 服务器的package.json 告诉Heroku在两个文件夹中安装依赖项的package.json 这是Heroku用来构建整个应用程序的package.json: { "name": "my-app",

我正在开发一个应用程序,它使用VueJS显示视图和充当服务器的ExpressJS

到目前为止,它在本地运行良好,但在Heroku上成功部署后,它不会加载应用程序并使dyno崩溃

我的文件夹结构如下所示:

  • 项目根
    • 客户
      • 客户端的package.json
    • 服务器
      • 服务器的package.json
    • 告诉Heroku在两个文件夹中安装依赖项的package.json
这是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
2017-12-08T14:55:35.408127+00:00应用程序[web.1]:找不到模块“eslint配置标准”
2017-12-08T14:55:35.408145+00:00应用程序[web.1]:引用自:/app/server/.eslintrc.js
2017-12-08T14:55:35.408945+00:00应用程序[web.1]:错误:找不到模块“eslint配置标准”
2017-12-08T14:55:35.408947+00:00应用程序[web.1]:引用自:/app/server/.eslintrc.js
2017-12-08T14:55:35.408948+00:00应用程序[web.1]:位于ModuleResolver.resolve(/app/server/node_modules/eslint/lib/util/module resolver.js:74:19)
2017-12-08T14:55:35.408949+00:00应用程序[web.1]:解析时(/app/server/node_modules/eslint/lib/config/config file.js:471:25)
2017-12-08T14:55:35.408950+00:00应用程序[web.1]:加载时(/app/server/node_modules/eslint/lib/config/config file.js:542:26)
2017-12-08T14:55:35.408951+00:00应用程序[web.1]:位于configExtends.reduceRight(/app/server/node_modules/eslint/lib/config/config file.js:421:36)
2017-12-08T14:55:35.408951+00:00应用程序[web.1]:at Array.reduceRight()
2017-12-08T14:55:35.408952+00:00应用程序[web.1]:在applyExtends(/app/server/node_modules/eslint/lib/config/config file.js:403:28)
2017-12-08T14:55:35.408953+00:00应用程序[web.1]:从磁盘加载(/app/server/node_modules/eslint/lib/config/config file.js:514:22)
2017-12-08T14:55:35.408953+00:00应用程序[web.1]:在Object.load(/app/server/node_modules/eslint/lib/config/config file.js:550:20)
2017-12-08T14:55:35.408954+00:00应用程序[web.1]:位于Config.getLocalConfigHierarchy(/app/server/node_modules/eslint/lib/Config.js:228:44)
2017-12-08T14:55:35.408955+00:00应用程序[web.1]:位于Config.getConfigHierarchy(/app/server/node_modules/eslint/lib/Config.js:180:43)
2017-12-08T14:55:35.464317+00:00应用程序[网站1]:npm错误!代码失效循环
2017-12-08T14:55:35.464681+00:00应用程序[web.1]:npm错误!错误1
2017-12-08T14:55:35.466080+00:00应用程序[web.1]:npm错误!server@1.0.0lint:`eslint**/*.js`
2017-12-08T14:55:35.466205+00:00应用程序[网站1]:npm错误!退出状态1
2017-12-08T14:55:35.466413+00:00应用程序[网站1]:npm错误!
2017-12-08T14:55:35.466555+00:00应用程序[网站1]:npm错误!失败server@1.0.0lint脚本。
2017-12-08T14:55:35.466726+00:00应用程序[网站1]:npm错误!这可能不是npm的问题。上面可能还有其他日志输出。
2017-12-08T14:55:35.491352+00:00应用程序[网站1]:
2017-12-08T14:55:35.491535+00:00应用程序[网站1]:npm错误!此运行的完整日志可在以下位置找到:
2017-12-08T14:55:35.491648+00:00应用程序[web.1]:npm错误/app/.npm/_logs/2017-12-08T14_55_35_468Z-debug.log
2017-12-08T14:55:35.506231+00:00应用程序[web.1]:[nodemon]应用程序崩溃-在启动前等待文件更改。。。
2017-12-08T14:56:08.700333+00:00 heroku[路由器]:at=错误代码=H20 desc=“应用程序启动超时”方法=GET path=“/status”host=babbelbord.herokuapp.com请求\u id=f86a8552-14b5-477c-b79d-d575ad30bffa fwd=“84.81.130”dyno=connect=service=status=503字节=protocol=https

您似乎从
/app/server/.eslintrc.js
中引用了
eslint配置标准
,但是您的package.json没有任何依赖项

您需要运行
npm install eslint config standard--save
,它将在package.json中创建一个依赖项。然后您应该保存以提交更改并再次部署到heroku


因为您没有在package.json中声明您的依赖关系,所以您的dyno将不知道如何安装它。我怀疑您只是忘记了将
--save
标志添加到原始的
npm安装
中,因此它只安装到
节点模块
文件夹中,而没有在
包中创建条目。感谢Heroku的支持,json

找到了答案。问题是我的依赖项是在package.json文件的
devDependencies
中定义的,而它们应该在
dependencies
中声明,以便Heroku正常工作。

感谢您帮助Elliot。然而,我检查了一下,我已经在devdependences中有了这个包。我用server package.json文件更新了这个问题,如果它可以帮助您,您可以从
/app/server/.eslintrc.js
提供代码吗?这将非常有用,因为代码似乎产生了错误。了解procfile正在调用的命令也将非常有用:)这是.eslintrc.js文件内容:module.exports={“extends”:“standard”};这是Procfile的内容:web:npm start--prefix server