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: Cannot find module 'is-odd' #4372
Comments
Hi! This repo is issues with the NodeJS core, and this looks like an issue with a package installation. But, to answer your question, modules are usually installed with If your experiencing an issue with Thank you! |
Thanks! @VoltrexKeyva, I believe this is a
|
They insist that is a |
Both forms of code run fine, so the dependencies are installed correctly // index.js
// node ./index.js
const isEven = require('is-even')
console.log(isEven(1)) // index.mjs
// node ./index.mjs
import * as isEven from 'is-even'
console.log(isEven.default(1)) Esbuild can also bundle correctly
|
I found an interesting thing. This line of code will affect the execution results. After commenting it out, it will only report an error the first time it is run. After that, it can run correctly every time. After removing the comment, it will report an error every time it is run. import fs from 'fs';
import { createServer } from 'net';
const mySocketFile = '/tmp/mysocketfile';
if (fs.statSync(mySocketFile, { throwIfNoEntry: false }))
fs.unlinkSync(mySocketFile);
// magic line
createServer((socket) => { }).listen(mySocketFile);
setTimeout(async () => {
const isEven = await import("is-even")
console.log("isEven: ", isEven.default(1))
});
|
@vfilatov Can you test using node 18? On my machine node18 doesn't have this problem |
Yes, this particular example working on node18. |
Yes, that is the point! |
Hi! If you delete the package-lock and pnpm-lock files and run |
Yes, it is working when I use |
So this probably isn't an issue with |
when I use |
So, despite what the |
It might an issue on both sides... As something changed between node18 & node20... |
Well, the change from Node.js v18 to Node.js v20 was breaking, as with major release lines, so breakages are expected, maybe the pnpm team knows? |
Someone more familiar with both libraries would need to investigate this in depth, and as a short-term solution, maybe try running it with bun for now? |
Marking as NPM ad this regards it vs pnpm |
Version
v20.12.1
Platform
Linux dev 5.10.0-28-amd64 nodejs/node#1 SMP Debian 5.10.209-2 (2024-01-31) x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
The original issue sveltejs/kit#11912
git clone https://github.com/gtm-nayan/node-socket-import-error.git cd node-socket-import-error/ rm package-lock.json pnpm-lock.yaml pnpm i node index.mjs
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
If package installed with
npm i
it does not throw the error belowWhat do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: