'Yarn berry installs node_modules

node.js version: 16.14.0 yarn version: 3.1.1 macOS: 11.6.4 (Big Sur)

I set up and continue to work on a yarn workspace project. I committed all files including .yarn, .pnp.cjs, .pnp.loader.mjs on the github repo.

However, I got an issue after I changed my computer.

When I tried to clone the repo and execute yarn install from my desktop computer, it deleted .pnp.cjs and .pnp.loader.mjs files and installed node_modules.

Other colleagues don't experience this issue, neither on my other laptop. Node and other versions are same.

I tried to delete and reinstall the repo several times, but the results went same, too.

I know that node_modules can be installed despite of using Yarn berry when the dependencies include binary. But I don't think this is the case.

Below is the shell message when node_modules is installed.

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 353ms
➤ YN0000: ┌ Link step
➤ YN0076: │ @swc/core-android-arm-eabi@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-android-arm64@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-darwin-arm64@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-freebsd-x64@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-arm-gnueabihf@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-arm64-gnu@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-arm64-musl@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-x64-gnu@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-x64-musl@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-win32-arm64-msvc@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-win32-ia32-msvc@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-win32-x64-msvc@npm:1.2.126 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-android-arm-eabi@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-android-arm64@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-darwin-arm64@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-freebsd-x64@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-arm-gnueabihf@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-arm64-gnu@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-arm64-musl@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-x64-gnu@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-linux-x64-musl@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-win32-arm64-msvc@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-win32-ia32-msvc@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0076: │ @swc/core-win32-x64-msvc@npm:1.2.133 The darwin-x64 architecture is incompatible with this module, link skipped.
➤ YN0000: └ Completed in 8s 368ms
➤ YN0000: Done with warnings in 9s 31ms

I got a different message when trying on my other computer which works well.

➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 428ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: Done with warnings in 0s 841ms


Solution 1:[1]

You are having .yarnrc.yml file in one of the parent directories with nodeLinker: node-modules option inside it (maybe in your user home folder?), find this file and remove it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Viktor Vlasenko