yarn
yarn copied to clipboard
Yarn link doesn't work
Do you want to request a feature or report a bug? Bug.
What is the current behavior?
foo@bar:~/code/lpserver/frontend/addons/lp-base$ yarn link
yarn link v0.16.1
success Registered "lp-base".
info You can now run `yarn link "lp-base"` in the projects where you want to use this module and it will be used instead.
Done in 0.05s.
foo@bar:~/code/lpserver/frontend/addons/lp-base$ cd ../../apps/partner/
foo@bar:~/code/lpserver/frontend/apps/partner$ yarn link lp-base
yarn link v0.16.1
success Registered "lp-base".
Done in 0.05s.
foo@bar:~/code/lpserver/frontend/apps/partner$ yarn
yarn install v0.16.1
info No lockfile found.
[1/4] Resolving packages...
error Couldn't find package "lp-base" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
If the current behavior is a bug, please provide the steps to reproduce. See above.
What is the expected behavior?
foo@bar:~/code/lpserver/frontend/addons/lp-base$ yarn link
yarn link v0.16.1
success Registered "lp-base".
info You can now run `yarn link "lp-base"` in the projects where you want to use this module and it will be used instead.
Done in 0.05s.
foo@bar:~/code/lpserver/frontend/addons/lp-base$ cd ../../apps/partner/
foo@bar:~/code/lpserver/frontend/apps/partner$ yarn link lp-base
yarn link v0.16.1
success Registered "lp-base".
Done in 0.05s.
foo@bar:~/code/lpserver/frontend/apps/partner$ yarn
yarn install v0.16.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.46s.
Please mention your node.js, yarn and operating system version.
node 6.4.0
yarn 0.16.1
Ubuntu 16.04 LTS
Probably, there is a bug when linked package name include the hyphen. The same problem may be in #1161.
Same problem with package with no hyphen in name; it still looks for package in on the "npm" registry.
Dead in the water without this working on my current project.
Any news on this?
I think I'm having the same issue (at least the result is the same).
If it helps, some details regarding my situation:
- building inside a Docker container, as "root", within a VM in Windows
- I have three packages locally under
/src-protected/tonidb/packagesnamedtonidb,tonidb-odmandtonidb-server. The last two depend ontonidband thus are linked usingyarn link tonidb. This works as the integrated tests succeed (yarn run test), so linking somehow works. - The main application under
/src-protected/winfarmer-xt/srcis linked to the three packages just mentioned, but fails with errors likeCouldn't find package "tonidb" on the "npm" registry.. The package name in the error message randomly switches between one of the three package names - I guess that's simple because of the parallel install. - Since the
tonidb*packages are unreleased to NPM yet, I've added them to thepackage.jsonfiles simply like"tonidb": "*". - Yarn version is v0.17.8.
I have no idea why the link works for the dependencies themselves but not for the main application.
Hmmm, anybody found a workaround?
Would like to use Yarn, but this is a major blocker :(
Yarn link seems completely broken? Would be great to get an update from the devs on this. Is anybody having luck using link at all?
Hey guys, let's try to use symbolic linking instead
$> ln -nsf ../foo node_modules/foo
It can be used into package.json:
"scripts": {
"link": "(mkdir node_modules || true) && ln -nsf ../foo node_modules/foo && ln -nsf ../bar node_modules/bar",
"setup": "yarn run link && yarn"
},
Just run setup task:
$> yarn run setup
Run into the same issue. After linking and install the package I got:
yarn
yarn install v0.23.2
[1/4] Resolving packages...
error Received malformed response from registry for "local-test". The registry may be down.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
We are going to revamp link: feature soon, see https://github.com/yarnpkg/rfcs/pull/34
Ok I will wait you guys, if you need some help let me know :)
@RusPosevkin could you confirm that if this issue has been resolved in v0.26 prerelease?
it does not seem to to work on latest prerelease
+1
I could not reproduce on latest [email protected]. Closing.
@fugufish and @alexre0, please provide a test script how I can reproduce it not working. Better open a new issue with the steps.
create a brand new package that is not registered on npm, use yarn link <package-name>
create project that references that package and version, use yarn link <package-name>
package correctly shows up in node_modules
call yarn install
an error will be thrown saying the package does not exist on the npm registry
first time you need to call yarn link without package name.
either way it doesn't work.
This is borked for me too - only when my dependency is installed locally can I get things to work, otherwise:
var gulp = require('gulp');
Error: Cannot find module 'gulp'
I think we are talking about different issues here.
@fugufish, do I understand it right that you yarn link project-b and also have a project-b in package.json?
I think Yarn may not work with linking and depending at the same time, it's probably a separate bug.
For a workaround you can try "project-b": "link:./path/to/project-b", it will create a symlink when you run yarn install.
@cloakedninjas, yarn would not run install on linked project, this is expected behavior. Workspaces feature should address this, it is still experimental
Pretty sure there’s still something messed up with this command. Here’s what I’m running into:
$ cd ~/code/some-module
$ yarn link
yarn link v0.17.8
success Registered "some-module".
info You can now run `yarn link "some-module"` in the projects where you want to use this module and it will be used instead.
✨ Done in 0.07s.
$ cd ../main-project
$ yarn link "some-module"
yarn link v0.17.8
error No registered module found called "some-module".
info Visit https://yarnpkg.com/en/docs/cli/link for documentation about this command.
What am I missing?

Can you do yarn link some-module without the double quotes?
Can you do yarn link some-module without the double quotes?
Exactly the same behaviour, regardless of presence/absence or quote type (' vs. ").
Oh wait, your yarn is version 0.17.8, that is very old, can you upgrade to latest? https://yarnpkg.com/en/docs/install
I'm getting the same thing as @cobyism. I've got the latest version of yarn. Create a link in node_modules, navigate to app folder, yarn link [package_name], package disappears from node_modules. The only way I can even fire up a server afterward is by reinstalling the package.
Same issues here.
Using yarn version 1.2.1, node version 8.4.0
Running the commands yarn link and yarn link some-module seems to work fine (at least yarn reports they went well), until I do a build and then get Cannot find module some-module error.
I am also running in this issue.
So the behavior I would expect is that yarn install skips the modules I already linked before
e.g.:
yarn link # in packages/local-test
# somewhere else
yarn link local-test
yarn install
# no longer tries to install local-test from registry
# even though it's in my package.json as a dependency
Currently, I am getting:
yarn install v1.3.2
[1/5] Validating package.json...
[2/5] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/local-test: Not found".
I get this with scoped packages, not sure if that's different.
Running into this issue as well, the same way @cobyism and @lgirma described
Seeing the same issue with yarn link. In the same boat with @Abdisalan
I was getting this error:
Error: Cannot find module '<package name>'
What worked for me was:
- run
yarn linkin the <package name> module directory. yarn buildthe <package name> module.- run
yarn link <package name>in the app directory I'm trying to include <package name> in.