Heroku:部署时出现npm错误

时间:2017-09-29 21:10:26

标签: node.js heroku npm

我的heroku日志中有一堆npm错误。我该如何开始调试呢?谢谢!

screenshot 的package.json

{
 "name": "server",
 "version": "1.0.0",
 "description": "",
 "main": "index.js",
 "engines": {
 "node": "8.1.1",
 "npm": "5.0.3"
},
 "scripts": {
 "start": "node index.js"
},
 "author": "",
 "license": "ISC",
 "dependencies": {
    "express": "^4.16.0"
 }
}

1 个答案:

答案 0 :(得分:1)

NPM ERR:缺少脚本:开始

您似乎错过了" start" package.json文件中的脚本。那是我开始寻找的地方。 Heroku可能会假设你事先设置了这个脚本。这是一个带有启动脚本的示例package.json文件:

{
    "name": "your-app",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": { // your npm scripts go here
        "start": "nodemon index.js", // or whatever server package you're using
        "lint:js": "node_modules/eslint/bin/eslint.js ./ ./**/*.js --fix; exit 0",
        "lint:css": "node_modules/csslint/cli.js public/css/; exit 0",
        "test": "NODE_ENV=test node_modules/mocha/bin/mocha"
    },
    "more": "settings below"
}

这是来自Heroku网站的简介:

  

指定启动脚本

     

要确定如何启动您的应用,Heroku首先会查找Procfile。如果Node.js应用程序不存在Procfile,我们将尝试通过package.json中的启动脚本启动默认Web进程。   Web进程类型中的命令必须绑定到PORT环境变量中指定的端口号。如果没有,那么dyno将无法启动。   有关更多信息,请参阅Node.js开发和Heroku Node.js支持的最佳实践。

https://devcenter.heroku.com/articles/deploying-nodejs

相关问题