【发布时间】:2026-01-29 16:40:01
【问题描述】:
我使用 Sails.js 创建了一个简单的应用程序并将其部署到 Heroku,它运行良好。
这是我的Procfile:
web: sails lift
但是在 Heroku 上(我认为)没有安装二进制 sails,那么它是如何工作的呢?
更新:
我已经从package.json 中删除了main 和start 部分,以防使用npm start 命令,但应用程序仍然可以正常运行。
我还在 Procfile 中添加了--prod 选项,并且处理正确。
这里是git push 输出(没有关于 Procfile 的警告/错误)
-----> Node.js app detected
PRO TIP: Specify a node version in package.json
See https://devcenter.heroku.com/articles/nodejs-support
-----> Defaulting to latest stable node: 0.10.28
-----> Downloading and installing node
-----> Restoring node_modules directory from cache
-----> Pruning cached dependencies not specified in package.json
-----> Writing a custom .npmrc to circumvent npm bugs
-----> Exporting config vars to environment
-----> Installing dependencies
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
-----> Building runtime environment
-----> Discovering process types
Procfile declares types -> web
-----> Compressing... done, 19.3MB
-----> Launching... done, v8
和heroku logs(进程以sails lift --prod 命令启动,而不是node app.js)
Slug compilation started
Slug compilation finished
Deploy 35bcbd9 by ...
Release v8 created by ..
Unidling
State changed from down to starting
Starting process with command `sails lift --prod`
memory, and will not scale past a single process.
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
info: Sails.js <|
info:
info: /|.\
info: v0.9.16 |\
info: `--'-------'
info: / || \
info: .-'.-==|/_--'
info: __---___--___---___--___---___--___
info: ,' |' \
info: To see your app, visit http://localhost:3661
debug: --------------------------------------------------------
info: Server lifted in `/app`
info: ____---___--___---___--___---___--___-__
info:
info: To shut down Sails, press <CTRL> + C at any time.
info:
debug: :: Sat May 17 2014 09:37:00 GMT+0000 (UTC)
debug:
debug: Environment : production
debug: --------------------------------------------------------
debug: Port : 3661
State changed from starting to up
【问题讨论】:
-
是的,我看不出你要去哪里...
-
我的猜测(这就是我没有将其标记为答案的原因)是,如果它确实没有全局安装sails,它会使用/尝试
npm start,因为它存在,它运行node app.js. -
@CWSpear,似乎并非如此 - 我已从
package.json中删除了start部分,一切正常。查看更新
标签: javascript node.js heroku sails.js