-
-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: No valid exports main found for 'node_modules\nanoid' #206
Comments
The ideal example of the issue 👍 Honestly, I am overworked right now. I will be able to look only a few days after. Can you look into the #205 happens because CRA does not support |
Until we will discover the problem, I added |
@ai No worries, I'll look into it tomorrow afternoon at the latest :) Thanks for the quick reply! |
Alright, it's been a while since I last did some good old fashioned detective work. Couldn't resist but to give it a go now. The first thing I tried was changing the Next up, I looked through the The Back on track with our error message, I searched through other issues on GitHub looking to pinpoint the line of code where the error message is constructed. This led me to find this issue: home-assistant/home-assistant-js-websocket#113 ... where the comment about using the new So I looked into how nanoid exports modules and noticed that I'm not familiar with the I haven't had a change to go through it in detail yet and try fixes, but at least it's something. |
Wow. So big research 😍 I will review it tomorrow, because I am going to sleep soon. Just want to say that you are great. |
Thanks! :D Here's a small update regarding I tried running
Both are set to the latest versions available through npm at the time of writing. So far it looks to be a ts-node issue. Are we running into this by chance? |
I added We use this But I found that you should use CommonJS in your package. So you must have: const { lib } = require('lib') Will moving to CommonJS solved you problem with |
I set up a project reflecting the fixture you provided. I still had the error. Then I realised that my test results aren't valid unless I ran the tests in the same Node environment you use. Assuming the latest version of Node is used to run the tests, I updated from 13.3.0 to 13.12.0. I tried... import { nanoid } from "nanoid"; ... and... const { nanoid } = require("nanoid"); After updating to Node 13.12.0 both worked without a problem! I will try and play around with some additional samples to see if anything else breaks. As it stands now this seemed to be caused by my older version of Node acting up. Thank you very much for your patience and expertise in figuring this out! |
Wow, Great! |
I think although |
@cansin creates a separate issue with all details of your project. What builder do you use? |
@cansin See the latest node 13 version is v13.14.0. Your version is very old. |
Wow, you guys are quick 😊 Ok, let me create a re-prod repo. Btw, if you are not supporting certain node versions, you should introduce an |
Ok, @ai @TrySound 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'
} Edited: Sorry, made a small mistake prior. Just force-pushed and updated the console output here for the correct repro a minute ago. |
Oh, sorry I should've created a separate issue. Will do that right away. |
Hello!
I was trying out nanoid in a TypeScript project and came across an issue when running the code through
ts-node-dev
.The setup
EDIT: Forgot to include I have Node 13.3.0 installed.
The issue occurs with nanoid version 3.0.2 when running
ts-node-dev
.Compilation with
tsc
passes without error.I was able to reproduce the issue with the following setup:
package.json
tsconfig.json
src/index.ts
Afterwards:
npm install
npm run start
The issue
Here is the complete transcript:
Other information
After downgrading to nanoid 2.1.11 everything worked fine, though I had to install @types/nanoid to get completion.
Older 3.x versions throw the same error.
I'm thinking
ts-node-dev
is at fault or something in my configuration, but seeing as how version 3.x is still fresh I figured it's worth to create an issue just to be safe.Might be related to #205?
The text was updated successfully, but these errors were encountered: