ERR_REQUIRE_ESM
ks221197 opened this issue ยท 4 comments
Getting error of Error [ERR_REQUIRE_ESM] while deploying nuxtjs 2.x.x application.
AWS EC2 : upgrade from AMI 1 to AMI 2
Node: 16.15.1
Npm: 8.11.0
Nuxtjs: 2.15.8
Scripts:
"build": "nuxt build",
"start": "./node_modules/pm2/bin/pm2 start pm2.config.json"
Errors:
Error [ERR_REQUIRE_ESM]: require() of ES Module /var/app/current/node_modules/string-width/index.js from /var/app/current/node_modules/wrap-ansi/index.js not supported.
Instead change the require of /var/app/current/node_modules/string-width/index.js in /var/app/current/node_modules/wrap-ansi/index.js to a dynamic import() which is available in all CommonJS modules.
at Module.Hook._require.Module.require (/var/app/current/node_modules/require-in-the-middle/index.js:80:39)
at Object. (/var/app/current/node_modules/@nuxt/cli/dist/cli-index.js:15:18)
at Object. (/var/app/current/node_modules/nuxt/bin/nuxt.js:6:1)
at /var/app/current/node_modules/pm2/lib/ProcessContainer.js:303:25
at wrapper (/var/app/current/node_modules/async/internal/once.js:12:16)
at WriteStream. (/var/app/current/node_modules/pm2/lib/Utility.js:186:13)
at WriteStream.emit (node:events:527:28)
at FSReqCallback.oncomplete (node:fs:188:23)
But i didn't install in my application, this package installing from nuxtjs package dependency. @sindresorhus
Im also having an issue with this while setting up husky + commitlint. In my case wrap-ansi is used within one of these and throws this error while I attempt to commit.
I'm also having this using husky+commitlint, could someone solve it?