Is there a way for npm install to install the devDevpendencies in a separate directory enabling the ability to run build tasks while excluding the devDependencies in a dynamic/simple way?
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'.
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.
Summary. For npm install specific version, use npm install [package-name]@[version-number]. Use npm view [package-name] version to know the specific latest version of a package available on the npm registry. Use npm list [package-name] to know the specific latest version of an installed package.
I don't think that's possible, https://www.npmjs.org/doc/files/npm-folders.html states that the modules have to be in node_modules
.
For your purposes you could copy everything but the node_modules
folder and do npm install --production
in the new copied folder, so you will only have production dependencies in the build.
This should accomplish what you want without much work:
rsync -av --progress yourproject yourbuilddir --exclude node_modules
cd yourbuilddir && npm install --production
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