Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8015643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:18:36+00:00 2026-06-04T20:18:36+00:00

Using npm we can install the modules globally using -g option. How can we

  • 0

Using npm we can install the modules globally using -g option. How can we do this in the package.json file?

Suppose, these are my dependencies in package.json file

"dependencies": {
    "mongoose": "1.4.0",
    "node.io" : "0.3.3",
    "jquery"  : "1.5.1",
    "jsdom"   : "0.2.0",
    "cron"    : "0.1.2"
  }

When i run npm install, I want only node.io to be installed globally, the rest others should be installed locally. Is there an option for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:18:38+00:00Added an answer on June 4, 2026 at 8:18 pm

    New Note: You probably don’t want or need to do this. What you probably want to do is just put those types of command dependencies for build/test etc. in the devDependencies section of your package.json. Anytime you use something from scripts in package.json your devDependencies commands (in node_modules/.bin) act as if they are in your path.

    For example:

    npm i --save-dev mocha # Install test runner locally
    npm i --save-dev babel # Install current babel locally
    

    Then in package.json:

    // devDependencies has mocha and babel now
    
    "scripts": {
      "test": "mocha",
      "build": "babel -d lib src",
      "prepublish": "babel -d lib src"
    }
    

    Then at your command prompt you can run:

    npm run build # finds babel
    npm test # finds mocha
    
    npm publish # will run babel first
    

    New NEW Note: For awhile now we have had npx, which allows you to run the devDependencies commands without needing to add them to your scripts section (if you want).
    For example:

    npx webpack
    

    But if you really want to install globally, you can add a preinstall in the scripts section of the package.json:

    "scripts": {
      "preinstall": "npm i -g themodule"
    }
    

    So actually my npm install executes npm install again … Which is weird but seems to work.

    Note: you might have issues if you are using the most common setup for npm where global Node package installs required sudo. One option is to change your npm configuration so this isn’t necessary:

    npm config set prefix ~/npm, add $HOME/npm/bin to $PATH by appending export PATH=$HOME/npm/bin:$PATH to your ~/.bashrc.

    Another, probably better option is to just use nvm to manage Node and you won’t have that problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to install express using npm, running this code: npm install express mongoose
I installed mongoose on node.js using npm. When I try to connect with this
I have this in my package.json file (shortened version): { name: a-module, version: 0.0.1,
I've installed NVM for node.js using the instructions from this post: http://www.backdrifter.com/2011/02/18/using-nvm-and-npm-to-manage-node-js/ When I
I have the following express node.js app. It's using the 'redis' npm package. app.get(/test,function(req,res){
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
I've started using npm for JavaScript package management recently. Although I do have a
I'm using the npm package express version 2.5.2 with node version .0.6.5. I appear
I'm trying to install Forever to use with Node.js. I'm installing it using 'npm
I had this problem initially, so I tried npm install --force It seems to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.