【问题标题】:Forever with npm start and environment variable永远使用 npm start 和环境变量
【发布时间】:2014-11-06 15:50:34
【问题描述】:

我曾经使用以下方式启动我的应用程序:

DEBUG=chakka ENVIRONMENT=production npm start

我怎样才能永远使用它,这样我就不必每次想要测试应用程序时都这样做?谢谢!

【问题讨论】:

    标签: node.js npm forever


    【解决方案1】:

    首先您需要知道应用程序的主脚本文件是什么。打开你的 package.json 文件并找出 start 脚本是什么。如果您使用 Express,它可能是 app.js。因此,我们将在此示例中假设 app.js,替换为您的文件。

    启动应用程序:

    DEBUG=chakka ENVIRONMENT=production forever start app.js
    

    在您进行更改后重新启动应用程序:

    forever restart app.js
    

    【讨论】:

    • 谢谢!你是一个救生员。 :)
    • 我试过这个但得到错误ENVIRONMENT=production forever start app.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file: app.js
    • 这些只是警告。如果您愿意,可以设置这些变量。
    猜你喜欢
    • 2019-01-30
    • 1970-01-01
    • 2013-01-15
    • 1970-01-01
    • 2015-02-28
    • 1970-01-01
    • 2013-05-29
    • 2017-08-02
    • 2018-11-28
    相关资源
    最近更新 更多