yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.34k stars 1.1k forks source link

`yarn dlx create-react-app` fails with message `Cannot find module 'pnpapi'` #4217

Open kjkent opened 2 years ago

kjkent commented 2 years ago

Hi there.

I'm using Yarn via corepack, detailed as best practice in the docs. Using yarn create react-app uses classic Yarn, and I was advised on Discord by @arcanis to use yarn dlx as an alternative, as this uses modern Yarn. When I do, I receive the following error:

error An unexpected error occurred: "/home/kjkent/dev/testapp/node_modules/core-js-pure: Cannot find module 'pnpapi'
Require stack:
- /home/kjkent/.node/corepack/yarn/1.22.15/lib/cli.js
- /home/kjkent/.node/corepack/yarn/1.22.15/bin/yarn.js
Require stack:
- /home/kjkent/.node/corepack/yarn/1.22.15/lib/cli.js
- /home/kjkent/.node/corepack/yarn/1.22.15/bin/yarn.js".

Looking at this and the yarn-error.log, Yarn is still using corepack's 1.22.15 classic Yarn for yarn dlx.

Any advice or clarification would be much appreciated; thanks.

yegorius commented 2 years ago

Having the same problem on Windows 11.

robv8r commented 2 years ago

I'm also having the same issue on Windows 11.

I'm using corepack, and have yarn 3.2.1 installed in my home directory:

C:\Users\robv8r\.node\corepack\yarn\3.2.1\yarn.js

The command I used was

yarn dlx create-react-app react-example

The result was an error

Yarn version: 
  1.22.19

Node version: 
  16.14.2

Platform: 
  win32 x64

Trace: 
  Error: C:\git\react-example\node_modules\core-js-pure: Cannot find module 'pnpapi'
  Require stack:
  - C:\Users\robv8r\.node\corepack\yarn\1.22.19\lib\cli.js
  - C:\Users\robv8r\.node\corepack\yarn\1.22.19\bin\yarn.js
  Require stack:
  - C:\Users\robv8r\.node\corepack\yarn\1.22.19\lib\cli.js
  - C:\Users\robv8r\.node\corepack\yarn\1.22.19\bin\yarn.js
      at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
      at Function.external_module_.Module._resolveFilename (C:\Users\robv8r~1\AppData\Local\Temp\xfs-01bc3ac1\dlx-13152\.pnp.cjs:10275:54)
      at Function.require.resolve (C:\Users\robv8r\.node\corepack\yarn\1.22.19\lib\v8-compile-cache.js:162:23)
      at C:\Users\robv8r\.node\corepack\yarn\1.22.19\lib\cli.js:34243:76
      at Generator.next (<anonymous>)
      at step (C:\Users\robv8r\.node\corepack\yarn\1.22.19\lib\cli.js:310:30)
      at C:\Users\robv8r\.node\corepack\yarn\1.22.19\lib\cli.js:321:13

npm manifest: 
  {
    "name": "react-example",
    "version": "0.1.0",
    "private": true
  }

yarn manifest: 
  No manifest

Lockfile: 
  No lockfile
momoclouq commented 2 years ago

same issue on windows 11

iamWing commented 1 year ago
yarn run v1.22.19
$ /private/var/folders/5l/0nyms7pj4fd275x81vpd74s00000gn/T/tmp-40958-Y7mWDYNK17ex/node_modules/.bin/nx new dts-web --no-allPrompts --no-a --no-skipGit --no-g '--commit.message=Initial commit' --/bin/sh=/Users/wing/.yarn/berry/cache/create-nx-workspace-npm-15.6.3-c1a8985181-8.zip/node_modules/create-nx-workspace/bin/index.js --name=dts-web --preset=angular-monorepo --appName=main --style=less --nxCloud --packageManager=yarn --defaultBase=master --ci= --nxWorkspaceRoot=/Users/wing/Projects/03_Work/DEVTO-Studio/web/02_code
info If you think this is a bug, please open a bug report with the information provided in "/private/var/folders/5l/0nyms7pj4fd275x81vpd74s00000gn/T/tmp-40958-Y7mWDYNK17ex/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

error An unexpected error occurred: "Cannot find module 'pnpapi'
Require stack:
- /Users/wing/.cache/node/corepack/yarn/1.22.19/lib/cli.js
- /Users/wing/.cache/node/corepack/yarn/1.22.19/bin/yarn.js
Require stack:
- /Users/wing/.cache/node/corepack/yarn/1.22.19/lib/cli.js
- /Users/wing/.cache/node/corepack/yarn/1.22.19/bin/yarn.js".

Same happened while using yarn via corepack to create nx workspace. Had to revert back to yarn create nx-workspace to get the project created then do yarn set version stable in the project root afterwards to use yarn 3.

Merlin04 commented 1 year ago

Still experiencing this issue :(

rtritto commented 1 year ago

This should related. yarn dlx @next/codemod@latest built-in-next-font .

Output:

➤ YN0000: · Yarn 4.0.0-rc.48
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @next/codemod@npm:13.4.12, @ampproject/remapping@npm:2.2.1, @babel/code-frame@npm:7.22.5, @babel/compat-data@npm:7.22.9, @babel/core@npm:7.22.9, and 350 more
➤ YN0000: └ Completed in 2s 326ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 355 packages were added to the cache (+ 9.14 MiB).
➤ YN0000: └ Completed in 0s 209ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed in 1s 395ms
➤ YN0000: · Done with warnings in 3s 978ms

C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.pnp.cjs:9445
      Error.captureStackTrace(firstError);
            ^

Error: @next/codemod tried to access .bin, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: .bin (via ".bin\jscodeshift")
Required by: @next/codemod@npm:13.4.12 (via C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.yarn\cache\@next-codemod-npm-13.4.12-25a6cef2a7-3057effaf3.zip\node_modules\@next\codemod\bin\)

Require stack:
- C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.yarn\cache\@next-codemod-npm-13.4.12-25a6cef2a7-3057effaf3.zip\node_modules\@next\codemod\bin\cli.js
- C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.yarn\cache\@next-codemod-npm-13.4.12-25a6cef2a7-3057effaf3.zip\node_modules\@next\codemod\bin\next-codemod.js
    at require$$0.Module._resolveFilename (C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.pnp.cjs:9445:13)
    at Function.resolve (node:internal/modules/helpers:125:19)
    at Object.<anonymous> (C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.yarn\cache\@next-codemod-npm-13.4.12-25a6cef2a7-3057effaf3.zip\node_modules\@next\codemod\bin\cli.js:24:41)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at require$$0.Module._extensions..js (C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.pnp.cjs:9488:33)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at require$$0.Module._load (C:\Users\<USER>\AppData\Local\Temp\xfs-c32ccfd1\dlx-21700\.pnp.cjs:9335:31)
    at Module.require (node:internal/modules/cjs/loader:1157:19)

Node.js v19.9.0