To illustrate the problem (bug) I have created a sample repo, which you can find at:
https://github.com/ApolloTang/issue-yarn-link-does-not-work
It has two folders: one has content which is the dependency package, the other a project that using the dependency package:
~/1/1-a/16-tools/yarn-link/issue-yarn-link-does-not-work
$ tree -F
.
├── dependency/
│  ├── index.js
│  ├── node_modules/
│  ├── package.json
│  └── yarn.lock
└── using-dependency/
├── index.js
└── package.json
in dependency/ folder:
$ yarn link
screenshot:
This created a link in my ~/.config/yarn/link
.
To confirm this :
cd ~/.config/yarn/link; ls -l
screenshot:
My ~/.config/yarn
has the following structure:
screenshot:
From the above the link is indeed pointing to my dependency folder. To confirm:
screenshot:
Now that the link has created I can cd to the project folder to link the dependency; However, I got
error No registered package found called ....
screenshot:
I also notice that if I go back to the dependency package folder, yarn can not unlink the package:
screenshot:
It seem like yarn link
does not know where the directory~/.config/yarn/link
is.
Here is the output of my yarn config list
:
Here is the content of my .yarnrc
:
screenshot:
duplicate of #1297 as "re-reported" by @cobyism, @fugufish, @JimmyCDChen and other.
yarn link dependency
(without quote) does not work [suggested by @travomic]yarn build
in dependency folder does not work, there is no such command yarn build
[suggested by @sandalsoft]the symbolic link is created in .config/yarn/link/
after all, but yarn link
command could not find it, could it be related to #2334, since I am using .config
(XDG specification)?
probably related: #6801
This issue also started happening for me. On yarn version 1.12.3
For me, it looks like the path that is set for the symbolic link is the absolute path prefixed with '../''s. Once this is fixed, yarn link works.
Jan 18 2020 - still happening.
ls -l symlink
says ../../../../../../absolute/path/here
What a bother.
The same problem, can not resolve the module even if the link is created.
version 1.21.1
I had the same problem. Only that, it was working few days ago. Later, when I changed the directory of my project, it stopped working. I tried linking again and it showed linked successfuly. Still, it throws a module not found error.
Same problem using lerna.
For a temporary solution, you can direct link by providing direct paths wherever you import that particular module and then rebuild the whole project.
import​ ​ CornerstoneViewport​ ​ from
'../../../react-cornerstone-viewport-2.1.0/src/CornerstoneViewport/Corn
erstoneViewport'​ ;
For a temporary solution, you can direct link by providing direct paths wherever you import that particular module and then rebuild the whole project.
import​ ​ CornerstoneViewport​ ​ from '../../../react-cornerstone-viewport-2.1.0/src/CornerstoneViewport/Corn erstoneViewport'​ ;
One other solution ( works but not always)
Add the repository name in the projects node modules folder ( directly along with the version) and rebuild.
A temporary solution I thought was to use file:path in package.json ... could be a better solution and avoid the various paths in the imports
It seems I found why it is not working as expect. My ~/.config
is a symlink, so the the symlink which yarn generate is totally wrong in a symlink folder. After making ~/.config
to a real folder, everything works well!
yes, my .config is a symlink !
I have a 'real' ~/.config
dir, and yarn link
is not working correctly.
Only I get no error messages. Or any other messages.
(I had to use Activity Monitor to SIGKILL node, as ctrl+c was leaving the webpack-dev-server
up, because reasons, I assume.)
The ui-kit (celula) builds just fine, and todos builds just fine without the kit.
Most helpful comment
It seems I found why it is not working as expect. My
~/.config
is a symlink, so the the symlink which yarn generate is totally wrong in a symlink folder. After making~/.config
to a real folder, everything works well!