Closed animanmaster closed 5 days ago
I'm having the same issue, any info?
Most likely missing the CommonJS module resolution in the engine.
The README seems to indicate that
require
-ing modules work, but when I tried to import a JS file that usesrequire()
, I got a'require' is not defined
error message. Is the README incorrect, or is there a way to make JS files that userequire
work?
I think the documentation is incorrect. I couldn't find any hint in QuickJS about it.
I also tested this workaround, but it leads to an error in QuickJS that the module is __null
.
There could be another issue when you want to use a nodeJS module like crypto
: I think it is not implemented in QuickJS, so you need to get another package from npm that simulates the same logic.
Maybe https://github.com/IvanGaravito/quickjs-require could be something (it was the first repo I found)?
Besides this, a lot of CommonJS Modules can be used in ECMAScript or in Typescript with npm install --save-dev @types/xxx
. Can you provide the module you used which didn't work as expected?
CommonJS is removed. We recommend using a packager such as Webpack to solve the use of npm libraries
The README seems to indicate that
require
-ing modules works, but when I tried to import a JS file that usesrequire()
, I get a'require' is not defined
error message. Is the README incorrect, or is there a way to make JS files that userequire
work?