【问题标题】:How to install node.js dependencies globally in app.js如何在 app.js 中全局安装 node.js 依赖项
【发布时间】:2014-05-20 13:28:55
【问题描述】:

我正在使用 node.js 和 express.js 创建一个 CMS。我正在创建我的 app.js 文件,并且想知道如何全局安装某些依赖项,以避免让用户自己安装这些模块。例如。该应用程序需要 nodemon 和 express-generator 模块。这些应该全局安装。

有没有办法让我通过依赖项区域或脚本区域全局安装这些依赖项?

提前谢谢你。

【问题讨论】:

标签: node.js express content-management-system node-modules


【解决方案1】:

感谢 Ahmad Hasan Khan,我能够找到问题的解决方案。

在您的 package.json 的脚本区域中,您的代码应该是这样的。

"scripts": {
    "start": "node app.js",
    "preinstall" : "npm -g nodemon"
},

参考 Install dependencies globally and locally using package.json

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-26
    • 2015-07-24
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-30
    相关资源
    最近更新 更多