question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to install npm packages into target directory?

See original GitHub issue

Even 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:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

8reactions
hwellmanncommented, Sep 25, 2016

That still doesn’t answer the original question.

From the Maven point of view, package.json is a source file, whereas node_modules/** is derived, and any derived files should be somewhere under target instead of polluting src 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.

6reactions
Nashorncommented, Jul 28, 2019

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found