【问题标题】:Node.js DEBUG=appname nodemon not working on windowsNode.js DEBUG=appname nodemon 在 Windows 上不起作用
【发布时间】:2019-02-22 16:21:57
【问题描述】:

我正在学习 Mosh 在 Node.js 中的教程,但我无法使这行代码工作。

    DEBUG=app:db nodemon index.js

我收到一个错误:

    'DEBUG' is not recognized as an internal or external command, 
     operable program or batch file.`

虽然最终它工作正常。

这仅适用于 MAC 吗?我也试过了

    set DEBUG=app:db nodemon index.js

但仍然得到同样的错误。

好吧,我已经看到并尝试了这些answers,但仍然不适合我。

有人能解释一下为什么这不起作用吗?

【问题讨论】:

    标签: node.js express


    【解决方案1】:

    使用windows,你必须用&&分隔命令:

    "scriptCommand": "set DEBUG=app:db&& nodemon index.js"

    请注意db&& 之间没有空格。这是有意为之,因为变量空间一直延伸到 && 墙 - 这意味着它会在 db 之后向您的变量添加一个无意的空间。

    此外,您可能想尝试非常有用且一目了然的cross-env 库,它允许您使用 1 种语法在项目初始化的任何环境(Win、Mac、Linux)中声明环境变量

    【讨论】:

      【解决方案2】:

      在 Windows 上试试这个“set DEBUG=app:* & nodemon index.js”。然后刷新浏览器,您将看到与数据库的连接。

      【讨论】:

        猜你喜欢
        • 2018-12-12
        • 1970-01-01
        • 1970-01-01
        • 2013-12-08
        • 1970-01-01
        • 2016-03-29
        • 1970-01-01
        • 2021-03-05
        • 1970-01-01
        相关资源
        最近更新 更多