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.

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

See original GitHub issue

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, https://github.com/vercel/next.js/issues/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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kherockcommented, Nov 18, 2021

@timmywil I also have that issue tracked here! https://github.com/vercel/next.js/issues/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.

1reaction
balazsorban44commented, Jan 24, 2022

@simPod I believe that has been fixed already in https://github.com/vercel/next.js/pull/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? 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

@jest/reporters | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Attempted import error: 'uuid' does not contain a default export ...
Because the uuid package has not default export, as the error clearly states. (it used to exist, but has been removed).
Read more >
Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >
https://opendev.org/skyline/skyline-console/raw/br...
yarn lockfile v1 "@ant-design/colors@^4.0.5": version "4.0.5" resolved ... data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" ...
Read more >
styled component cannot be used as a jsx component - You.com
A component needs to return a single root element. You can use fragments to package an array of elements as a single element,...
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