简体   繁体   中英

How to install node.js dependencies globally in app.js

I am creating a CMS with node.js and express.js. I am creating my app.js file and would like to know how to install certain dependencies globally, to avoid having the user install these modules on their own. For instance. The app requires nodemon and the express-generator modules. Those should be installed globally.

Is there a way for me to install these dependencies globally either via the dependencies area or via the scripts area ?

Thank you in advance.

Thanks to Ahmad Hasan Khan, I was able to find the solution to my question.

Within the scripts area of your package.json your code should like like this.

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

Reference Install dependencies globally and locally using package.json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM