我正在学习使用node和express,我使用express生成器来设置一个基本项目并将其推送到heroku,但是我在日志中遇到了这个错误:
2015-12-27T16:29:01.478244+00:00 heroku[web.1]: Starting process with command `npm start`
2015-12-27T16:29:03.533736+00:00 app[web.1]:
2015-12-27T16:29:03.522320+00:00 app[web.1]:
2015-12-27T16:29:03.522335+00:00 app[web.1]: > application-name@0.0.1 start /app
2015-12-27T16:29:03.522337+00:00 app[web.1]: > nodejs ./bin/www
2015-12-27T16:29:03.522337+00:00 app[web.1]:
2015-12-27T16:29:03.526805+00:00 app[web.1]: sh: 1: nodejs: not found
2015-12-27T16:29:03.537910+00:00 app[web.1]: npm ERR! Linux 3.13.0-71-generic
2015-12-27T16:29:03.538285+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-12-27T16:29:03.538482+00:00 app[web.1]: npm ERR! node v0.12.7
2015-12-27T16:29:03.540540+00:00 app[web.1]: npm ERR! npm v2.11.3
2015-12-27T16:29:03.540543+00:00 app[web.1]: npm ERR! file sh
2015-12-27T16:29:03.540544+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-12-27T16:29:03.540544+00:00 app[web.1]: npm ERR! errno ENOENT
2015-12-27T16:29:03.540545+00:00 app[web.1]: npm ERR! syscall spawn
2015-12-27T16:29:03.540547+00:00 app[web.1]: npm ERR! spawn ENOENT
2015-12-27T16:29:03.540546+00:00 app[web.1]: npm ERR! application-name@0.0.1 start: `nodejs ./bin/www`
2015-12-27T16:29:03.540547+00:00 app[web.1]: npm ERR!
2015-12-27T16:29:03.540548+00:00 app[web.1]: npm ERR! Failed at the application-name@0.0.1 start script 'nodejs ./bin/www'.
2015-12-27T16:29:03.540549+00:00 app[web.1]: npm ERR! This is most likely a problem with the application-name package,
2015-12-27T16:29:03.540549+00:00 app[web.1]: npm ERR! not with npm itself.
2015-12-27T16:29:03.540550+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-12-27T16:29:03.540551+00:00 app[web.1]: npm ERR! nodejs ./bin/www
2015-12-27T16:29:03.540552+00:00 app[web.1]: npm ERR! You can get their info via:
2015-12-27T16:29:03.540714+00:00 app[web.1]: npm ERR! npm owner ls application-name
2015-12-27T16:29:03.540922+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-12-27T16:29:03.543464+00:00 app[web.1]:
2015-12-27T16:29:03.543727+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-12-27T16:29:03.543869+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2015-12-27T16:29:04.374697+00:00 heroku[web.1]: Process exited with status 1
2015-12-27T16:29:04.392014+00:00 heroku[web.1]: State changed from starting to crashed
当我改变这个
时,它开始工作了"scripts": {
"start": "nodejs ./bin/www"
},
到这个
"scripts": {
"start": "node ./bin/www"
},
但我不知道为什么,任何人都可以解释node和nodejs之间的区别,以及它如何与heroku一起工作。
THX
答案 0 :(得分:0)
Express生成器创建一个启动脚本,该脚本运行命令node ./bin/www
,通过运行.bin/www
JavaScript文件启动Express应用程序。问题是没有命令标记为nodejs
,但有一个名为node
(指向node.js可执行文件)。
Nodejs(node.js)通常简称为node
,通常用于命令提示。