I'm trying to set up some CI tests that rely on a few Node modules, but don't require installing everything in package.json. I figured I could do this like so:
npm install --no-save eslint stylelint stylelint-config-standard stylelint-order stylelint-scss
Doing that, however, still installs everything from my devDependencies
in package.json. How can I tell NPM to ignore my package.json, and only install what I'm specifically telling it to?
EDIT: To better demonstrate the problem I'm running in to, I deleted node_modules
out of one of my projects, and attempted to run npm install --no-save mkdirp
. mkdirp is a very simple module with one dependency, but as you can see from the output below, NPM went ahead and still installed everything in my package.json
.
jacob@RYZEN:~/Repositories/new-site$ npm install --no-save mkdirp
> [email protected] install /mnt/c/Users/Jacob/Repositories/new-site/node_modules/puppeteer
> node install.js
Downloading Chromium r588429 - 103.7 Mb [====================] 100% 0.0s
Chromium downloaded to /mnt/c/Users/Jacob/Repositories/new-site/node_modules/puppeteer/.local-chromium/linux-588429
> [email protected] install /mnt/c/Users/Jacob/Repositories/new-site/node_modules/node-sass
> node scripts/install.js
Cached binary found at /home/jacob/.npm/node-sass/4.9.3/linux-x64-57_binding.node
> [email protected] postinstall /mnt/c/Users/Jacob/Repositories/new-site/node_modules/gifsicle
> node lib/install.js
✔ gifsicle pre-build test passed successfully
> [email protected] postinstall /mnt/c/Users/Jacob/Repositories/new-site/node_modules/jpegtran-bin
> node lib/install.js
✔ jpegtran pre-build test passed successfully
> [email protected] postinstall /mnt/c/Users/Jacob/Repositories/new-site/node_modules/optipng-bin
> node lib/install.js
✔ optipng pre-build test passed successfully
> [email protected] postinstall /mnt/c/Users/Jacob/Repositories/new-site/node_modules/pngquant-bin
> node lib/install.js
✔ pngquant pre-build test passed successfully
> [email protected] postinstall /mnt/c/Users/Jacob/Repositories/new-site/node_modules/node-sass
> node scripts/build.js
Binary found at /mnt/c/Users/Jacob/Repositories/new-site/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
> [email protected] postinstall /mnt/c/Users/Jacob/Repositories/new-site/node_modules/swiper
> node -e "console.log('\u001b[35m\u001b[1mLove Swiper? Support Vladimir\'s work by donating or pledging on patreon:\u001b[22m\u001b[39m\n > \u001b[32mhttps://patreon.com/vladimirkharlampidi\u001b[0m\n')"
Love Swiper? Support Vladimir's work by donating or pledging on patreon:
> https://patreon.com/vladimirkharlampidi
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ [email protected]
added 1969 packages from 803 contributors and audited 24004 packages in 201.431s
found 21 vulnerabilities (4 low, 8 moderate, 9 high)
run `npm audit fix` to fix them, or `npm audit` for details
By default, npm install will install all modules listed as dependencies in package. json .
To add dependencies and devDependencies to a package. json file from the command line, you can install them in the root directory of your package using the --save-prod flag for dependencies (the default behavior of npm install ) or the --save-dev flag for devDependencies.
npm install (directory)When a folder argument is specified, npm install downloads everything from the specified location to the original node_modules directory at the root of the project.
NPM installs devDependencies within the package. json file. The 'npm install' command should add all the dependencies and devDependencies automatically during installation. If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'.
I've figured out why this is happening; apparently if you have a package-lock.json
, NPM always installs everything in there regardless of the flags you pass. The solution is the --no-package-lock
flag.
npm install --no-package-lock --no-save --quiet stylelint-config-standard stylelint-order stylelint-scss
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With