Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip specific modules during npm install

Tags:

npm

In my development project I have package.json that contains 3 groups of dependencies:

  • Standard dependencies from the public NPN repositories
  • Dependencies from an internal development repository that requires a certain proxy configuration and permissions
  • Dependencies from an internal financial repository that requires its own proxy and permissions

Our build integration machine is the only one set-up to be able to pull all dependencies, while all Dev machines cannot, which creates a nightmare of dependency installation.


Is it possible to tell NPM within the install command to install all except, and provide the list of modules in package.json to be skipped during the installation?

Otherwise, what is the best way to deal with such a situation, considering that getting all the proxies set up with all the permissions isn't realistic?

like image 266
vitaly-t Avatar asked Dec 19 '22 01:12

vitaly-t


1 Answers

You can use another way like "optionalDependencies" described in the official documentation here:

https://docs.npmjs.com/cli/v6/configuring-npm/package-json#optionaldependencies

Example:

{
  "dependencies": {
    "some-package-name-1": "1.0.0"
  },
  "devDependencies": {
    "some-package-name-2": "1.0.0"
  },
  "optionalDependencies": {
    "some-package-name-3": "1.0.0"
  }
}

and call

npm install --no-optional

it will install only the following:

some-package-name-1, some-package-name-2
like image 187
Марат Зимнуров Avatar answered Jan 21 '23 18:01

Марат Зимнуров