Npm - set default prefix / path for a specific project

I would like to npm ...always run in the context of a subfolder of my project: "./assets".

When I run this command from the root of the project, it behaves as expected:

$ npm --prefix ./assets install

However, it does not read this from .npmrcin the root folder.

$ echo "prefix=./assets" > .npmrc
$ npm i
# creates an empty ./node_modules folder

How can I set the prefix for a specific project for npm commands?

+4
source share
1 answer

If you install npm all over the world, you can simply configure the installation prefix for a specific folder so that you can install other node modules in that folder. The following is the command to set the prefix.

npm/Programming/ node-v0.10.31-linux-x64/

node node -v0.10.31-linux-x64, node .

node ,

npm install bower -g --prefix/Programming/ node-v0.10.31-linux-x64/

-1

Source: https://habr.com/ru/post/1673337/


All Articles