question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default nodeLinker is node_modules instead of pnp

See original GitHub issue

When I create a new project with yarn berry, the default value of nodeLinker is node-modules as default. It should be pnp (source).

How can I reset the default value (equal to the initial setup of yarn) of nodeLinker to pnp?

Steps to reproduce

  1. yarn init -y
  2. yarn set version berry
  3. yarn add @yarnpkg/sdks -D node_modules folder is created
  4. yarn sdks

Results

Actual

Internal Error: This tool can only be used with projects using Yarn Plug'n'Play
    at SdkCommand.execute (C:\test-node-linker\node_modules\@yarnpkg\sdks\lib\commands\SdkCommand.js:39:19)
    at SdkCommand.validateAndExecute (C:\test-node-linker\node_modules\clipanion\lib\advanced\Command.js:64:37)
    at Cli.run (C:\test-node-linker\node_modules\clipanion\lib\advanced\Cli.js:132:38)
    at Cli.runExit (C:\test-node-linker\node_modules\clipanion\lib\advanced\Cli.js:149:39)
    at Object.<anonymous> (C:\test-node-linker\node_modules\@yarnpkg\sdks\lib\cli.js:16:5)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)

Expect

Usage Error: No integrations have been provided as arguments, and no preexisting integrations could be found. Make sure to run `yarn sdks <integrations>` first, or `yarn sdks base` if you only need the SDK files and prefer to manage your own environment settings. Run `yarn sdks -h` to see the list of supported integrations.

$ sdks [--cwd #0] [-v,--verbose] ...

Versions

yarn: 3.0.2 OS: Windows 10

Workaround

To change manually value of nodeLinker to pnp, I added in .yarnrc.yml:

nodeLinker: pnp
...

Then I run yarn command and I got:

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0031: │ One or more node_modules have been detected and will be removed. This operation may take some time.
➤ YN0000: └ Completed
➤ YN0000: Done with warnings

Now when I run yarn sdks command, I got log in expected results.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
clemyancommented, Sep 28, 2021

@rtritto Check if C:\Users\<User>\.yarnrc.yml exists and if it sets nodeLinker.

If no, then running yarn config --why instead of yarn config will tell you the path of the config file that sets each config.

0reactions
tgelucommented, Feb 15, 2022

@clemyan I have .yarnrc.yml file in C:\Users\<User> with nodeLinker: node-modules. I solved removing it.

Anyway with yarn config --why command:

...
➤ YN0000: nodeLinker                    /C:/Users/<User>/.yarnrc.yml               'node-modules'
...

Thanks!

After hours of debugging around the same issue I ended up here, which fixed it!

In my case the root cause of those files being generated in \Users\<User>\.yarnrc.yml was from running yarn somewhere outside a project by mistake. Strange that it initializes a project at that level. And this in combination with adding a .yarnrc.yml with a nodeLinker that overwrites the default is hard to catch if you’re unfamiliar with yarn berry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plug'n'Play | Yarn - Package Manager
In this install mode (the default starting from Yarn 2.0), Yarn generates a single .pnp.cjs file instead of the usual node_modules folder containing...
Read more >
get rid of node_modules with Yarn Plug'n'Play - Medium
When you enable PnP, instead of copying every needed file from the cache to the node_modules folder, here's what Yarn does:.
Read more >
Yarn Plug'n'Play vs node_modules - Gap Intelligence
This feature allows us to run Node.js projects without using the node_modules folder, which normally establishes the project dependencies.
Read more >
Node-Modules configuration options with pnpm
By default, pnpm v5 will create a semi-strict node_modules. ... The default configuration looks like this: ... node-linker=pnp symlink=false ...
Read more >
yarn pnp fallback to default require - node.js - Stack Overflow
'node_modules', 'transport') ). I cannot find a way to say to yarn@3.0.1 to do the fallback to the filesystem. I read about the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found