uuidjs/uuid

Package subpath './v1' is not defined by "exports" in [my project path]\node_modules\uuid\package.json

JC9thCO opened this issue · 3 comments

Describe the bug

I've installed uuid into my environment and added these 2 lines of code:

const uuid = require('uuid/v1');
const nodeAddress = uuid(); 

And now my app won't start. Getting the following error:

npm start

> myappname@1.0.0 start
> nodemon --watch dev -e js dev/api.js

[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): dev\**\*
[nodemon] watching extensions: js
[nodemon] starting `node dev/api.js`
node:internal/modules/cjs/loader:488
      throw e;
      ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v1' is not defined by "exports" in [app path redacted]\node_modules\uuid\package.json
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:440:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:692:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> ( [app path redacted]\dev\api.js:5:14) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

How to reproduce

REQUIRED: Provide a Minimal, Complete, and Verifiable example so that we (the uuid maintainers) can reproduce the problem. Issues that do not provide this will be closed without investigation.

Add the 2 lines above and attempt to start the app?

Expected behavior

If I comment out those lines, and set nodeAddress to a random string, it startes just fine:

npm start

> myappname@1.0.0 start
> nodemon --watch dev -e js dev/api.js

[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): dev\**\*
[nodemon] watching extensions: js
[nodemon] starting `node dev/api.js`
Listening on port 3000!

Runtime

  • OS: Windows 11
  • Runtime: Node.js
  • Runtime Version: v16.13.2

Additional information

const { v1: uuid } = require('uuid');

Thanks! Struggled with this issue on upgrade. Maybe "const uuid = require('uuid/v1')" worked in previous versions?

@fnsfroskos It was removed in v8 major 2 years ago