nodejs / nodejs/require-in-the-middle

ERR_REQUIRE_ESM

Open
#52 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
186
Forks
34
PR merge metrics
No merged PRs in 30d

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the deployment with AWS AMI 2, Node 16.15.1, npm 8.11.0, and Nuxt 2.15.8. Trace the require-in-the-middle entry point through @nuxt/cli, nuxt/bin/nuxt.js, and the string-width/wrap-ansi error, then establish a verified resolution for the reported ERR_REQUIRE_ESM failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, nodejs, nuxtjs
Domain
devops, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.