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

12.0.2 regression: can no longer import uuid package (a package with exports) with yarn pnp #31226

Closed
timmywil opened this issue Nov 9, 2021 · 9 comments
Labels
bug Issue was opened via the bug report template.

Comments

@timmywil
Copy link
Contributor

timmywil commented Nov 9, 2021

What version of Next.js are you using?

12.0.2, 12.0.3, and 12.0.4-canary.3

What version of Node.js are you using?

16.13.0

What browser are you using?

Chrome, Safari, Vivaldi, Brave

What operating system are you using?

macOS and Windows

How are you deploying your application?

N/A (yarn dev and yarn build)

Describe the Bug

There seems to be a regression in 12.0.2 where I can no longer import the package "uuid" (and some others) when using yarn pnp. The full error looks like this:

error - unhandledRejection: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'uuid' imported from C:\code\test-uuid-no-typescript\.next\server\pages\index.js
Did you mean to import uuid-no-typescript/.yarn/cache/uuid-npm-8.3.2-eca0baba53-5575a8a75c.zip/node_modules/uuid/dist/index.js?
error - Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'uuid' imported from C:\code\test-uuid-no-typescript\.next\server\pages\index.js
Did you mean to import uuid-no-typescript/.yarn/cache/uuid-npm-8.3.2-eca0baba53-5575a8a75c.zip/node_modules/uuid/dist/index.js?

That error text is from windows, but it's the same on mac.

At first, #30393 seemed like it might be related, but I only started experiencing my issue in 12.0.2. If I revert to 12.0.1, everything works as expected.

I'm not sure what it is about this package that next doesn't like. It has exports set in its package.json, but that's not a new thing.

Expected Behavior

No error when compiling the page.

To Reproduce

$ yarn create next-app # and follow instructions
$ cd package
$ yarn set version berry && yarn config set nodeLinker pnp && yarn
$ yarn add uuid # and add an import of uuid in pages/index.js
$ yarn dev # then visit localhost:3000

Minimal reproduction: https://github.com/timmywil/test-nextjs-yarn-uuid

Note that this repo does not include typescript.

Also note that you still get this error when swc is disabled.

@timmywil timmywil added the bug Issue was opened via the bug report template. label Nov 9, 2021
@kherock
Copy link

kherock commented Nov 9, 2021

duplicate of #30873

@timmywil
Copy link
Contributor Author

timmywil commented Nov 10, 2021

Yes, I missed that one. Could keep this one tho since it has a reproduction to test when yarn deploys their fix.

@timmywil
Copy link
Contributor Author

This may not be related, but yarn recently released their fix to canary and I tried it in the reproduction. It fixed the issue during page compilation when running next dev, but next build just hangs forever. I'm experiencing the same in my project.

Again, this is not using a stable version of yarn pnp, but it may be worth a look.

@kherock
Copy link

kherock commented Nov 18, 2021

@timmywil I also have that issue tracked here! #31279

Not a yarn bug, it's actually an incompatibility with custom ESM loaders and Next.js's use of jest-worker. You can work around it by adding experimental: { workerThreads: true } to your next.config.js.

@simPod
Copy link
Contributor

simPod commented Jan 24, 2022

that gives me "Error: Failed to read source code "

warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
info  - Checking validity of types...
warn  - The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config
info  - Creating an optimized production build...
(node:697) [DEP_WEBPACK_MODULE_UPDATE_HASH] DeprecationWarning: Module.updateHash: Use new ChunkGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
Failed to compile.
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/page-loader.js
Error: Failed to read source code from /builds/projects/a/121816/client/.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/page-loader.js
Caused by:
    No such file or directory (os error 2)
Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/index.js
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/next.js
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/script.js
Error: Failed to read source code from /builds/projects/a/121816/client/.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/script.js
Caused by:
    No such file or directory (os error 2)
Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/index.js
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/next.js
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/pages/_error.js
Error: Failed to read source code from /builds/projects/a/121816/client/.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/pages/_error.js
Caused by:
    No such file or directory (os error 2)
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/amp.js
Error: Failed to read source code from /builds/projects/a/121816/client/.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/amp.js
Caused by:
    No such file or directory (os error 2)
Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/head.js
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/head.js
./src/components/App/App.tsx
./pages/_app.ts
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/router-context.js
Error: Failed to read source code from /builds/projects/a/121816/client/.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/router-context.js
Caused by:
    No such file or directory (os error 2)
Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/index.js
./.yarn/__virtual__/next-virtual-762dcf18b2/6/cache/yarn/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/next.js
> Build failed because of webpack errors

@balazsorban44
Copy link
Member

@simPod I believe that has been fixed already in #33236 on canary. Could you test that out?

@timmywil would you also give it a go with canary and the above recommendations to see if this is still an issue? 🙏

@timmywil
Copy link
Contributor Author

@balazsorban44 My issue is fixed on canary, and using yarn set version canary. And the build does not hang as long as experimental: { workerThreads: true } is added to the next config.

@simPod
Copy link
Contributor

simPod commented Jan 26, 2022

@balazsorban44 seems like it's still there :/

I'm using yarn-3.2.0-rc.12.cjs

trace
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/normalize-trailing-slash.js
Error: Failed to read source code from /a/.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/normalize-trailing-slash.js

Caused by:
    No such file or directory (os error 2)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/router/router.js
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/router.js

./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/page-loader.js
Error: Failed to read source code from /a/.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/page-loader.js

Caused by:
    No such file or directory (os error 2)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/index.js
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/next.js

./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/portal/index.js
Error: Failed to read source code from /a/.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/portal/index.js

Caused by:
    No such file or directory (os error 2)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/index.js
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/next.js

./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/vitals.js
Error: Failed to read source code from /a/.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/vitals.js

Caused by:
    No such file or directory (os error 2)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/index.js
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/client/next.js

./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/head-manager-context.js
Error: Failed to read source code from /a/.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/head-manager-context.js

Caused by:
    No such file or directory (os error 2)

Import trace for requested module:
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/shared/lib/head.js
./.yarn/__virtual__/next-virtual-762dcf18b2/0/cache/next-npm-12.0.8-aa55acca00-947f0295aa.zip/node_modules/next/dist/pages/_error.js

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants