Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM Issues continue with Next.JS #848

Open
Yukigamine opened this issue Nov 9, 2023 · 2 comments
Open

ESM Issues continue with Next.JS #848

Yukigamine opened this issue Nov 9, 2023 · 2 comments
Labels

Comments

@Yukigamine
Copy link

Bug Description

Same error as #762 still happening after the fix released in v1.4.4.
Next.js webpack configuration detection failed with the following error Error [ERR_REQUIRE_ESM]: require() of ES Module...

Code snippets

Where the dependency is used:

N/A

Where the dependency is listed in package.json:

    "dependencies": {
        "@fortawesome/fontawesome-svg-core": "^6.4.2",
        "@fortawesome/free-solid-svg-icons": "^6.4.2",
        "@fortawesome/react-fontawesome": "latest",
        "@prisma/client": "latest",
        "chart.js": "^4.4.0",
        "chartjs-adapter-moment": "^1.0.1",
        "chartjs-plugin-annotation": "^3.0.1",
        "moment": "^2.29.4",
        "node-cron": "^3.0.2",
        "papaparse": "^5.4.1",
        "react-dymo-hooks": "^2.0.2",
        "react-select": "^5.7.7",
        "swr": "^2.2.4"
    },
    "devDependencies": {
        "@types/node": "20.8.8",
        "@types/node-cron": "^3.0.10",
        "@types/papaparse": "^5.3.10",
        "@types/react": "18.2.32",
        "cron": "^3.1.6",
        "debug": "^4.3.4",
        "depcheck": "^1.4.7",
        "eslint": "8.52.0",
        "eslint-config-next": "^13.5.6",
        "eslint-config-prettier": "^9.0.0",
        "eslint-plugin-sonarjs": "^0.21.0",
        "husky": "^8.0.3",
        "lint-staged": "^15.0.2",
        "next": "^13.5.6",
        "prettier": "^3.0.3",
        "prisma": "latest",
        "react": "^18.2.0",
        "react-chartjs-2": "^5.2.0",
        "react-dom": "^18.2.0",
        "stylelint": "^15.11.0",
        "stylelint-config-prettier": "^9.0.5",
        "stylelint-config-standard": "^34.0.0",
        "supports-color": "^9.4.0",
        "tsx": "^3.14.0",
        "typescript": "5.2.2"
    },

Versions

  • node -v: v20.8.1
  • npm -v: 10.1.0
  • yarn -v: 3.5.1
  • depcheck --version: 1.4.7

Extra info

Any extra info you want to include. Thank you for the bug report!

BONUS POINTS: If you wish to help us debug further, the depcheck --json option will show more information.

depcheck.json.txt

@Yukigamine Yukigamine added the bug label Nov 9, 2023
@ivanlen
Copy link

ivanlen commented Dec 4, 2023

Same here

  • node: v16.13.2
  • npm: 8.1.2
  • depcheck: 1.4.7
Next.js webpack configuration detection failed with the following error Error [ERR_REQUIRE_ESM]: require()...

@bencmbrook
Copy link

bencmbrook commented Dec 13, 2023

Looks like the dist is not targeting ESM, so import await() gets transpiled to require()

const nextConfig = await import(filepath);

becomes:

Screenshot 2023-12-12 at 10 03 10 PM

so when next.config.js is an ES Module, you'll get Error [ERR_REQUIRE_ESM]: require() of ES Module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants