nanoid: Error: No valid exports main found for '/path/to/nanoid'

As initially described at https://github.com/ai/nanoid/issues/206#issuecomment-622967848 , I am getting a MODULE_NOT_FOUND error with node@13.2.0 and yarn@1.22.4.

Here is the repro: https://github.com/cansin/nanoid-module-not-found-repro

And a sample run on my local:

cansin@localhost nanoid-repro % node --version
v13.2.0
cansin@localhost nanoid-repro % yarn --version
1.22.4
cansin@localhost nanoid-repro % yarn install
yarn install v1.22.4
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
[5/5] 🔨  Building fresh packages...

✨  Done in 0.09s.
cansin@localhost nanoid-repro % node index.js 
internal/modules/cjs/loader.js:614
  throw e;
  ^

Error: No valid exports main found for '/Users/cansin/code/nanoid-reprod/node_modules/nanoid'
    at resolveExportsTarget (internal/modules/cjs/loader.js:611:9)
    at applyExports (internal/modules/cjs/loader.js:492:14)
    at resolveExports (internal/modules/cjs/loader.js:541:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:643:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:941:27)
    at Function.Module._load (internal/modules/cjs/loader.js:847:27)
    at Module.require (internal/modules/cjs/loader.js:1016:19)
    at require (internal/modules/cjs/helpers.js:69:18)
    at Object.<anonymous> (/Users/cansin/code/nanoid-reprod/index.js:1:20)
    at Module._compile (internal/modules/cjs/loader.js:1121:30) {
  code: 'MODULE_NOT_FOUND'
}

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (17 by maintainers)

Most upvoted comments

@marcelo-michels The latest node 13 should work fine. The problem happens only with early versions.

The warning is OK

Thanks for the repo. I will take a look today or tomorrow.