Node.js Heroku网站:npm错误!缺少脚本:开始

Node.js Heroku网站:npm错误!缺少脚本:开始,node.js,heroku,procfile,Node.js,Heroku,Procfile,Heroku web正在抛出错误:npm ERR!缺少脚本:开始 但是,当我在本地运行它时:heroku local web。 项目已成功构建 我已将我的package.json中的启动脚本设置为: "scripts": { "start": "node server" } 根据文档,如果我没有指定Procfile,默认情况下它应该是npm start 但是,我也尝试添加Procfile: 文件内容 web: npm start 它抛出同样的错误 日志输出:heroku日志-Ny

Heroku web正在抛出错误:
npm ERR!缺少脚本:开始

但是,当我在本地运行它时:
heroku local web
。 项目已成功构建

我已将我的package.json中的启动脚本设置为:

"scripts": {
    "start": "node server"
  }
根据文档,如果我没有指定Procfile,默认情况下它应该是
npm start

但是,我也尝试添加Procfile:

文件内容

web: npm start
它抛出同样的错误

日志输出:
heroku日志-Nyptest

Niteshs-MacBook-Pro:nyps nitesh$ heroku logs -a nypstest
2016-06-15T07:01:44.024250+00:00 heroku[api]: Release v3 created by nitesh@campusdiaries.com
2016-06-15T07:01:44.023668+00:00 heroku[api]: Scale to web=1 by nitesh@campusdiaries.com
2016-06-15T07:01:44.429595+00:00 heroku[slug-compiler]: Slug compilation started
2016-06-15T07:01:44.429603+00:00 heroku[slug-compiler]: Slug compilation finished
2016-06-15T07:01:46.222149+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-15T07:01:49.138230+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-15T07:01:49.141111+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-15T07:01:49.139367+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-15T07:01:49.139986+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-15T07:01:49.160916+00:00 app[web.1]: 
2016-06-15T07:01:49.145755+00:00 app[web.1]: npm ERR! 
2016-06-15T07:01:49.146073+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-15T07:01:49.143580+00:00 app[web.1]: 
2016-06-15T07:01:49.146389+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2016-06-15T07:01:49.161685+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-15T07:01:49.161369+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-15T07:01:49.145444+00:00 app[web.1]: npm ERR! missing script: start
2016-06-15T07:01:50.132213+00:00 heroku[web.1]: Process exited with status 1
2016-06-15T07:01:50.152654+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-15T07:01:50.151676+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-15T07:01:52.430686+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-15T07:01:55.754745+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-15T07:01:55.753213+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-15T07:01:55.759649+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-15T07:01:55.754205+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-15T07:01:55.755673+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-15T07:01:55.759409+00:00 app[web.1]: npm ERR! 
2016-06-15T07:01:55.759143+00:00 app[web.1]: npm ERR! missing script: start
2016-06-15T07:01:55.757612+00:00 app[web.1]: 
2016-06-15T07:01:55.759874+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2016-06-15T07:01:55.772868+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-15T07:01:55.772730+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-15T07:01:55.772370+00:00 app[web.1]: 
2016-06-15T07:01:56.675716+00:00 heroku[web.1]: Process exited with status 1
2016-06-15T07:01:56.687035+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-15T07:03:23.527948+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=b064f04d-b6b8-4655-adc4-c4bbdb4db70a fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:03:26.783968+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=dfa98acd-5291-46df-85e6-ec2d7bd1afa0 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:25:30.940961+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-15T07:25:33.374221+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-15T07:25:35.711736+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-15T07:25:35.712514+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-15T07:25:35.712824+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-15T07:25:35.713260+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-15T07:25:35.714628+00:00 app[web.1]: 
2016-06-15T07:25:35.716136+00:00 app[web.1]: npm ERR! missing script: start
2016-06-15T07:25:35.716418+00:00 app[web.1]: npm ERR! 
2016-06-15T07:25:35.716638+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-15T07:25:35.716866+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2016-06-15T07:25:35.726294+00:00 app[web.1]: 
2016-06-15T07:25:35.726558+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-15T07:25:35.726717+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-15T07:25:36.541486+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-15T07:25:36.529432+00:00 heroku[web.1]: Process exited with status 1
2016-06-15T07:25:55.677715+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=d67c3c7f-1b0c-4ae4-8066-f539c676c813 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:25:56.970694+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=a5e959df-5c6b-475e-883d-668fffc3b1ca fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:37:15.873210+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=83d3f406-22ba-4649-81c4-261889c6f26d fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:37:17.263994+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=b24ecc40-99ed-4ee4-8975-850f02880751 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:40:31.730476+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=46c7351c-6818-466c-b816-fab8686a3a26 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:40:32.902969+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=a29d2281-9931-412d-befb-4788284e6dc3 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:40:46.425659+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=69f32408-7b94-41ed-a692-3874bb87125e fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:40:47.283575+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=82645270-a085-49f0-8bdd-8ffbd417e136 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:46:45.562741+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=d6b356f1-e7f3-4e74-a9bc-7834b6ddaa39 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T07:46:46.792388+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=0df4dfd9-5368-41b3-a658-37c80effc3c5 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T08:09:20.166494+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-15T08:09:22.215228+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-15T08:09:25.009624+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-15T08:09:25.010335+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-15T08:09:25.010667+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-15T08:09:25.011377+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-15T08:09:25.013096+00:00 app[web.1]: 
2016-06-15T08:09:25.014247+00:00 app[web.1]: npm ERR! missing script: start
2016-06-15T08:09:25.014442+00:00 app[web.1]: npm ERR! 
2016-06-15T08:09:25.014622+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-15T08:09:25.014765+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2016-06-15T08:09:25.025073+00:00 app[web.1]: 
2016-06-15T08:09:25.025367+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-15T08:09:25.025542+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-15T08:09:25.854231+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-15T08:09:25.844519+00:00 heroku[web.1]: Process exited with status 1
2016-06-15T08:26:54.120685+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=8e5dbaff-ba8a-4a2f-a4f5-b56e6aba2871 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T08:26:55.251426+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=ada7aaf7-a2c6-4f98-b387-3f201102b09c fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T08:36:41.113185+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=e412adc8-0d6f-45c9-b30d-06774366132e fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T08:36:42.534191+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=bcc98a01-93d2-40b8-91ce-d59f67f54c7a fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T09:32:52.373988+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-15T09:32:54.422584+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-15T09:32:57.749315+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-15T09:32:57.751518+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-15T09:32:57.753827+00:00 app[web.1]: 
2016-06-15T09:32:57.755515+00:00 app[web.1]: npm ERR! 
2016-06-15T09:32:57.750410+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-15T09:32:57.750924+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-15T09:32:57.755280+00:00 app[web.1]: npm ERR! missing script: start
2016-06-15T09:32:57.773805+00:00 app[web.1]: 
2016-06-15T09:32:57.755821+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2016-06-15T09:32:57.755662+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-15T09:32:57.774094+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-15T09:32:57.774273+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-15T09:32:58.841956+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-15T09:32:58.826851+00:00 heroku[web.1]: Process exited with status 1
2016-06-15T09:49:37.707537+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nypstest.herokuapp.com request_id=bc832c95-120e-4b59-ad83-7dd95f7081f8 fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
2016-06-15T09:49:39.156404+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nypstest.herokuapp.com request_id=0f6b252e-8e67-47b1-9c21-c41eea09e0ef fwd="106.51.141.204" dyno= connect= service= status=503 bytes=
Niteshs-MacBook-Pro:nyps nitesh$ 
server.js

var webpack = require('webpack')
var webpackDevMiddleware = require('webpack-dev-middleware')
var webpackHotMiddleware = require('webpack-hot-middleware')
var config = require('./webpack.config')
var serveStatic = require('serve-static');
var sendMail = require('./src/api/sendmail');
var bodyParser = require('body-parser');
var app = new (require('express'))()

var port = process.env.WEBPACK_PORT || 3000

var compiler = webpack(config)
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }))
app.use(webpackHotMiddleware(compiler))

// parse application/json
app.use(bodyParser.json());

    // parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));


app.get('*', function(req, res) {
  res.sendFile(__dirname + '/index.html')
})




app.listen(port, function(error) {
  if (error) {
    console.error(error)
  } else {
    console.info("==> you have to change "main" in package.json to server.js

also you can do:

"scripts": {
  "start": "node server.js",
  "test": "mocha",
  "postinstall": "bower install && grunt build"
}
var webpack=require('webpack'))
var webpackDevMiddleware=require('webpack-dev-middleware')
var webpackHotMiddleware=require('webpack-hot-middleware')
var config=require(“./webpack.config”)
var serveStatic=require('service-static');
var sendMail=require('./src/api/sendMail');
var bodyParser=require('body-parser');
var app=new(require('express'))()
var port=process.env.WEBPACK|u port | 3000
var编译器=网页包(配置)
使用(webpackDevMiddleware(编译器,{noInfo:true,publicPath:config.output.publicPath}))
应用程序使用(WebPackageHotMiddleware(编译器))
//解析应用程序/json
use(bodyParser.json());
//解析应用程序/x-www-form-urlencoded
use(bodyParser.urlencoded({extended:true}));
app.get('*',函数(req,res){
res.sendFile(uu dirname+'/index.html')
})
应用程序侦听(端口、功能(错误){
如果(错误){
控制台错误(错误)
}否则{
console.info(“==>您必须将package.json中的“main”更改为server.js

您还可以执行以下操作:

"main": "app.js",
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start" : "node app.js"
  },


所有内容看起来都是正确的。请确保Procfile的名称正确,并且位于正确的文件夹中。

问题可能在于文件的嵌套方式。如果您有一个git存储库,其中包含另一个包含代码的文件,那么pa

我有三个相同的js名称以及我的主js文件,它对我有效。

在package.json中。
“main”:“app.js”,
“脚本”:{
“开始”:“node app.js”
}

并且在Procfile中

web:node app.js

我遇到了同样的问题,我的服务器在app.js文件上,我更改了package.json文件,如下所示:

web: node app.js
和proc文件作为

我重做了heroku的创建过程

这是它的链接:


我认为这会很有帮助

你能发布你的完整的
包.json吗?嗨,谢谢你的回复。我已经添加了完整的包.json。请看一看你的嗨,谢谢你的回复。我试过了。这也不起作用。作为替代,你可以在Procfile中指定:web:node index.js**看到你意外地你的答案有没有删去一部分?最后一句似乎不完整。
web: node app.js