Can't get const {v3: uuidV4 } = require('uuid') to work in project
ShaunB-SQ opened this issue · 6 comments
Describe 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.
shaun@LAP600758:~/gitrepos/sqaccfin/server$ npm ls uuid
sqaccfin@1.7.0 /home/shaun/gitrepos/sqaccfin/server
├─┬ aws-sdk@2.1136.0
│ └── uuid@3.3.2
├─┬ mssql@5.1.5
│ └─┬ tedious@4.2.0
│ └─┬ adal-node@0.1.28
│ ├─┬ request@2.88.2
│ │ └── uuid@3.4.0
│ └── uuid@3.4.0
├─┬ sequelize@4.44.4
│ └── uuid@3.4.0
└── uuid@7.0.3
it works this time when I reloaded the links which really is weird since I copied the error message directly from page once I saw it errored out in the sandbox.
the only thing I can think of is this seems to be in one of the other dependencies I haven't updated quite yet that need uuid as well.
with winston in this project I am not even getting a stack trace so its really hard to track down right now.
Closing, pending further investigation. Let us know what you find and we'll reopen if appropriate.
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.