Is there a way to install npm packages into target directory?
See original GitHub issueEven using the configuration specified in the readme the node_modules
folder is created at the package.json
level:
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
<installDirectory>target</installDirectory>
</configuration>
</execution>
Is it possible to install these packages into a different directory in a smart way (as example without to copy the package.json
into such folder)?
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
How to npm install to a specified directory? - Stack Overflow
There currently is no documented way to install a package in an arbitrary directory. You should change into the target directory ...
Read more >How to install npm packages to a specified directory - Reactgo
To install the packages into a specified directory, we need to use the --prefix option followed by the directory path.
Read more >How to install specified directory using npm ? - GeeksforGeeks
Open up a javascript project in an editor and decide on which directory you want to install the npm package, we can also...
Read more >How to npm install to a specified directory | Edureka Community
The package (s) will then be installed in ./install/here/node_modules. The mkdir is needed since npm might otherwise choose an already ...
Read more >Run npm install in a different directory - Nerdy Mishka
I find that trying to run NPM install for all dependencies in a different folder than where the package.json resides,… a bit troublesome....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That still doesn’t answer the original question.
From the Maven point of view,
package.json
is a source file, whereasnode_modules/**
is derived, and any derived files should be somewhere undertarget
instead of pollutingsrc
or the base directory.So it doesn’t really matter what the default behaviour of npm is, the question is if this default can or should be overridden by
frontend-maven-plugin
so that the npm build step behaves like a good citizen in Maven land.What a serious drawback of the NPM architecture, installing any and everything into a hardcoded “node_modules” folder. Thats just shi* design.
How nice it would of been to declare each dependency in package.json, pointing to it’s own target directory?