Can't get const {v3: uuidV4 } = require('uuid') to work in project
See original GitHub issueDescribe the bug
On node v16.14.2
trying to update an older project’s npm packages to their latest.
on uuid@7.0.3 this works
const { v4: uuidV4 } = require('uuid');
console.log(uuidV4());
v7.0.3 https://codesandbox.io/s/node-playground-forked-6u253w
changed from
const uuid = require(uuid')
console.log(uuid.v4);
However as soon as I install uuid@8.3.2
I get this error from winston | 2022-05-17T17:35:45.953Z error: ERR_PACKAGE_PATH_NOT_EXPORTED
;
and this in codesandbox.io
ModuleNotFoundError: Could not find module in path: 'uuid/dist/esm-browser/stringify.js' relative to '/node_modules/uuid/dist/esm-browser/v1.js'
at ge.resolveModule (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:130422)
at ge.resolveTranspiledModuleSync (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:131313)
at c (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112264)
at $csb$eval (https://6u253w.csb.app/node_modules/uuid/dist/esm-browser/v1.js:7:27)
at H (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:99995)
at K.evaluate (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112747)
at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:123129)
at c (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112362)
at $csb$eval (https://6u253w.csb.app/node_modules/uuid/dist/esm-browser/index.js:6:49)
at H (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:99995)
at K.evaluate (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112747)
at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:123129)
at c (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112362)
at $csb$eval (https://6u253w.csb.app/src/index.js:3:16)
at H (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:99995)
at K.evaluate (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112747)
at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:123129)
at c (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112362)
at loadResources (https://6u253w.csb.app/index.html:3:2)
at $csb$eval (https://6u253w.csb.app/index.html:9:3)
at H (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:99995)
at K.evaluate (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:112747)
at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:123129)
at ge.evaluateModule (https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:122628)
at https://codesandbox.io/static/js/sandbox.8af77dda6.js:1:318342
at c (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:3629)
at Generator._invoke (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:3382)
at Generator.forEach.t.<computed> [as next] (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:3986)
at r (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:206)
at u (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:417)
v8.3.2 https://codesandbox.io/s/node-playground-forked-qx2z9v
Expected behavior
That the default way to require a module would work and wouldn’t have to change EVERY OTHER require in the project to an import for this to work going forward.
You 8.0.0 change log https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md#800-2020-04-29 even suggests doing it this way.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Cannot find module 'uuid/v4' · Issue #238 - GitHub
Hi, I install uuid module on my Windows 10 64bit with WebStorm and NodeJS 8.8.1 but when I require the module I get...
Read more >Can't resolve 'uuid/v4' in react-native - Stack Overflow
navigate to that file, and look around line number 3 in ... const { v4: uuidv4 } = require('uuid'); ... This worked for...
Read more >Module not found: Can't resolve 'uuid/v4' - Super User
Install uuid library via node package manager i.e. npm npm install uuid. Then import uuidv4 from uuid library const { v4: uuidv4 } ......
Read more >uuidv4 - npm
First you need to integrate uuidv4 into your project by using the require function: const { uuid } = require('uuidv4');. If you use...
Read more >3 efficient ways to generate UUID in Node.js
In this post, you will learn how to generate a UUID using Node.js and briefly understand when and why to use them. Let's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did find the issue, there where other places in my code that was requiring uuid/v4 and I never found it when I did a search for ‘uuid’.
those other references switched to
const { v4: uuidV4 } = require('uuid');
fixed my issue.Closing, pending further investigation. Let us know what you find and we’ll reopen if appropriate.