Error [ERR_REQUIRE_ESM]: Must use import to load ES Module


I have been getting this error on production, but it works fine in my local when I try to preview using netlify dev this is the error:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /var/task/node_modules/@steeze-ui/heroicons/index.js
require() of ES modules is not supported.
require() of /var/task/node_modules/@steeze-ui/heroicons/index.js from /var/task/.netlify/server/entries/pages/__layout.svelte.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /var/task/node_modules/@steeze-ui/heroicons/package.json.

Site Name:
Framework: SvelteKit
Functions: No


  "name": "timesheet",
  "version": "0.0.1",
  "scripts": {
    "dev": "svelte-kit dev --host",
    "build": "svelte-kit build",
    "package": "svelte-kit package",
    "preview": "svelte-kit preview",
    "test": "playwright test",
    "check": "svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
    "lint": "prettier --check --plugin-search-dir=. . && eslint .",
    "format": "prettier --write --plugin-search-dir=. ."
  "devDependencies": {
    "@playwright/test": "^1.22.2",
    "@rgossiaux/svelte-headlessui": "^1.0.2",
    "@steeze-ui/heroicons": "^1.1.1",
    "@steeze-ui/svelte-icon": "^1.3.1",
    "@sveltejs/adapter-auto": "next",
    "@sveltejs/kit": "next",
    "@tailwindcss/forms": "^0.5.2",
    "@tsconfig/svelte": "^3.0.0",
    "@typescript-eslint/eslint-plugin": "^5.27.0",
    "@typescript-eslint/parser": "^5.27.0",
    "autoprefixer": "^10.4.7",
    "daisyui": "^2.17.0",
    "eslint": "^8.16.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-svelte3": "^4.0.0",
    "netlify": "^11.0.2",
    "postcss": "^8.4.14",
    "prettier": "^2.6.2",
    "prettier-plugin-svelte": "^2.7.0",
    "svelte": "^3.44.0",
    "svelte-check": "^2.7.1",
    "svelte-preprocess": "^4.10.7",
    "tailwindcss": "^3.1.4",
    "tslib": "^2.3.1",
    "typescript": "^4.7.2"
  "type": "module",
  "dependencies": {
    "firebase": "^9.8.4",
    "nanoid": "^4.0.0",
    "yup": "^0.32.11"


  "extends": "./.svelte-kit/tsconfig.json",
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true


  command = "npm run build"
  publish = "build"
  node_bundler = "esbuild"

One of the support topics is that this issue can be solved by adding functions in their .toml config hence I added it, but I’m still facing the issue. I’m not using netlify functions

Did you try to change your require() statement to import?

the error is from a third-party package. but this run’s fine when running and building in local

Hey there, @Pardhav :wave:

Thanks so much for following up. Can you share how you know that the error is coming from the third-party package? Additionally, did you try @hrishikesh’s suggestion above? (changing your require() statement to import ?)

Lastly, can you share a link to the full build log in the UI where you see the error?