Reputation: 14500
Since I have a docker image for node js and want to install global node_modules directory as well as local using volumes e. g a part of my docker-compose file looks as below.
...
node:
image: node
volumes:
- ./webroot:/var/app
- ./global_node_modules:/var/node_global
environment:
- NPM_CONFIG_PREFIX=/var/node_global
- YARN_CONFIG_PREFIX=/var/node_global
- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/node_global/bin
working_dir: /var/app
stdin_open: true
tty: true
I have ./global_node_modules
directory which is mapped to a volume on node container /var/node_global
where I want to install global packages
when I run npm --global
or yarn global add
. npm is respecting the env variable NPM_CONFIG_PREFIX
but that is not true for yarn. e.g
After npm install vue-cli --global
ls -al /var/node_global/bin
vue -> ../lib/node_modules/vue-cli/bin/vue
vue-init -> ../lib/node_modules/vue-cli/bin/vue-init
vue-list -> ../lib/node_modules/vue-cli/bin/vue-list
After yarn global add vue-cli
ls -al /var/node_global/bin
vue -> ../../../usr/local/share/.config/yarn/global/node_modules/vue-cli/bin/vue
vue-init -> ../../../usr/local/share/.config/yarn/global/node_modules/vue-cli/bin/vue-init
vue-list -> ../../../usr/local/share/.config/yarn/global/node_modules/vue-cli/bin/vue-list
I was wondering what makes yarn install file in different directory. It seems to be linking the binaries but that is not sufficient.
Upvotes: 2
Views: 1338
Reputation: 170698
Do not use YARN_CONFIG_PREFIX
, is no longer supported by current versions and will trigger a runtime error:
Usage Error: Unrecognized or legacy configuration settings found: configPrefix - run "yarn config -v" to see the list of settings supported in Yarn (in <environment>)
$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] [--require #0] <scriptName> ...
Upvotes: 0