lukeed / polka

A micro web server so fast, it'll make you dance! :dancers:
MIT License
5.4k stars 172 forks source link

Error: Cannot find module 'node:querystring' #215

Closed Magesh3590 closed 1 week ago

Magesh3590 commented 2 weeks ago

Error: Cannot find module 'node:querystring'

LOKIE98 commented 2 weeks ago

I'm also facing this issue after the recent update from 1.0.0.next.24 to 1.0.0.next.27. This is one change I can find const qs = require('node:querystring'); -> in 1.0.0.next.27 const qs = require('querystring'); -> in 1.0.0.next.24

nogashimoni commented 2 weeks ago

Same here :(

lukezavrel commented 2 weeks ago

Same here, i temporary fixed the issue by adding "@polka/url": "1.0.0-next.25" to my package.json

orange9912 commented 2 weeks ago

Same here, or switch the node version to 16

cihanselim commented 2 weeks ago

+1

temporarily solved it by adding the following lines to the package.json:

"resolutions": { "@polka/url": "1.0.0-next.24" },

!! I use yarn. if you use npm, change resolutions to overrides

mitjap commented 2 weeks ago

What version of node are you guys running?

xqin commented 1 week ago

What version of node are you guys running?

node v14.16.0

xqin commented 1 week ago

@lukeed

Please unpublish version of v1.0.0-next.27 first, thanks.

This is a breaking change and should not use a patch version number.

lukeed commented 1 week ago

I take it you’re all using Node < 16, but are you using import or require syntax?

xqin commented 1 week ago

I take it you’re all using Node < 16, but are you using import or require syntax?

require

UnhandledPromiseRejectionWarning: Error: Cannot find module 'node:querystring'
Require stack:
- /app/node_modules/@polka/url/build.js
- /app/node_modules/sirv/build.js
- /app/node_modules/webpack-bundle-analyzer/lib/viewer.js
- /app/node_modules/webpack-bundle-analyzer/lib/index.js
- /app/node_modules/**********/lib/configs/webpack.base.config.js
- /app/node_modules/**********/lib/configs/webpack.prod.config.js
- /app/node_modules/**********/lib/adapter.js
- /app/node_modules/**********/lib/index.js

https://unpkg.com/sirv@2.0.4/build.js

image
xqin commented 1 week ago

@lukeed The use of @polka/url package is an indirect dependency.

➜  app npm list @polka/url
app@1.0.0 /opt/app
└─┬ webpack-bundle-analyzer@4.10.2
  └─┬ sirv@2.0.4
    └── @polka/url@1.0.0-next.27

The question is: why does sirv depend on the next version of @polka/url, but the stable version?

And it seems that the sirv package is also maintained by you.

Should the sirv package adjust its dependence on @polka/url to be a stable version?

lukeed commented 1 week ago

I just published a 1.0.0-next.28 for all packages, which strips the node: prefix for all CommonJS packages. You will get these files via a require statement.

The ESM version of each package still has the node: prefix. You will only get this version if you are using import syntax. The node: prefix was added in 16.x and back-ported to 14.18 (docs), so ensure you're on at least one of those versions. While native ESM was technically added in 12.x, it's been end-of-life (including security) for ~3 years and its version of "ESM" is significantly broken/different than today's ESM... 12.x was the first (experimental) ESM release.

xqin commented 1 week ago

Verified, thank you for the quick response :)

alex921131958 commented 1 week ago

quick response :)