maska
maska copied to clipboard
ERR_REQUIRE_ESM
I import a module in a vue component and get an error on the server side rendering context:
Error [ERR_REQUIRE_ESM]: require() of ES Module /.../node_modules/maska/dist/maska.umd.js from /.../node_modules/vue-server-renderer/build.dev.js not supported.
maska.umd.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename maska.umd.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /.../node_modules/maska/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
I use the custom webpack build with vue 2 ssr
I found that the problem goes away if for example i remove "type": "module"
from package.json
or rename maska.umd.js
to maska.umd.cjs
But UMD is not CJS. What about browsers? Looks like we need third format for CJS or some corrections of package.json.
I'm not sure, but in my case it worked both in the browser and on ssr. As far as I understand, "type": "module" in the package.json file indicates that the package should be read as ES module and it causes an error when trying to read .umd as an ES module. You may want to remove "type": "module" from package.json?
Could you please provide minimal repo that gives such error?
Hi @beholdr it seems this issue has gone stale, but has there been any thought to type: module
in package.json
? I too am getting this error in vanilla JS setup using Rollup. Similar to Mad-Head removing type: module
solves the issue.
I was able to get around this by installing v 1.5.2
, but I'd love to use the newer features if possible.
Thanks
@matt-meagher Hi, can you please create minimal repo with such error?
Thanks for getting back to me @beholdr. I actually cannot recreate outside of my storybook environment, and unfortunately cannot share that. I'm going to look for alternatives.
Jest (jest": "^27.5.1") in tests cannot import this module, although this library itself is tested using Jest, surrealism)
I have just released v3-beta. Could you check if this issue still actual?
Closing as inactive.