yarn link not creating global module link (npm behavior)

Created on 8 Dec 2016  路  2Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

bug (in as it relates to npm behavior)

What is the current behavior?

Running yarn link on a package folder does not add a symlink to the global packages for yarn, preventing it from being required as a global package elsewhere.

If the current behavior is a bug, please provide the steps to reproduce.

cd /my-module
yarn link

Trying to require('my-module') globally does not work.

What is the expected behavior?

I'd expect this to behave like npm where a npm link will allow the module to be required globally.

Please mention your node.js, yarn and operating system version.

Node 6. Yarn 0.18.0. MacOS Sierra.

Most helpful comment

I can't replicate your behavior at all with normal npm. Just running npm link does create symlinks into /usr/local/lib/node_modules, but that path is not on the node package search tree by default (at least on OS X 10.12).

I think yarn link has the correct behavior - as you want to explicitly link your development/local copy into other packages, not immediately turn it on as a global for all node packages, which could potentially cause many unforeseen issues.

cd my-module
yarn link
cd ../other-module
yarn link my-module

All 2 comments

As an aside. I get around this now by:

cd my-module
yarn link
cd ~/.config/yarn/global
yarn link my-module

I can't replicate your behavior at all with normal npm. Just running npm link does create symlinks into /usr/local/lib/node_modules, but that path is not on the node package search tree by default (at least on OS X 10.12).

I think yarn link has the correct behavior - as you want to explicitly link your development/local copy into other packages, not immediately turn it on as a global for all node packages, which could potentially cause many unforeseen issues.

cd my-module
yarn link
cd ../other-module
yarn link my-module
Was this page helpful?
0 / 5 - 0 ratings