Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] yarn install caches dependencies, but won't create node_modules #2581

Closed
1 task
gh-andre opened this issue Mar 8, 2021 · 3 comments
Closed
1 task
Labels
bug Something isn't working

Comments

@gh-andre
Copy link

gh-andre commented Mar 8, 2021

  • I'd be willing to implement a fix

Describe the bug

When adding a package, Yarn 2.4.1 goes fetches and caches requested packages, but there's no node_modules created after it reports success.

To Reproduce

Set up Yarn:

npm install -g yarn
mkdir test && cd ~/test
yarn set version berry

package.json:

{
"name": "test",
"private": true,
"license": "UNLICENSED",
"version": "0.1.0"
}

Add lodash:

yarn add lodash

This fetches lodash and stores it in .yarn/cache/lodash-npm-4.17.21-*.zip and adds it to dependencies in package.json and to yarn.lock, but doesn't create node_modules.

Running yarn install succeeds through all steps and nothing is changed in the directory structure.

Running yarn info lodash shows all info, as if it's installed.

Running the same with Yarn 1.22.10 works fine and creates node_modules after adding lodash.

Screenshots

N/A

Environment if relevant (please complete the following information):

  • OS: Linux/Fedora 33/CentOS 8
  • Node version: Fedora 33: 14.15.4, CentOS 8: 10.24.0
  • Yarn version: global 1.22.10, local 2.4.1

Additional context

This is similar to the issue described in this old thread.

yarnpkg/yarn#2240

@gh-andre gh-andre added the bug Something isn't working label Mar 8, 2021
@merceyz
Copy link
Member

merceyz commented Mar 8, 2021

See https://yarnpkg.com/getting-started/migration, if you want node_modules you have to explicitly enable it

@merceyz merceyz closed this as completed Mar 8, 2021
@gh-andre
Copy link
Author

gh-andre commented Mar 8, 2021

I see. I must say, running everything through the package manager, and with explicit opt-out telemetry settings, looks a bit more radical than I expected. Thanks for pointing it out, though. Much appreciated.

@ticmaidev
Copy link

this is what worked for me in berry version:
yarn config set nodeLinker node-modules

I guess it's also possible to set it as a per project basis:
nano .yarnrc.yml
nodeLinker: node-modules

it's also probably required removing these files:
rm -rf .pnp.cjs .pnp.loader.mjs
rm -rf yarn.lock .yarn

then run install again:
yarn install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants