question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

npm run build with AntDesignVueResolver [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/home/project/node_modules/ant-design-vue/es' is not supported resolving ES modules

See original GitHub issue

i have tried to set cjs to both true and false to build, but same error. using all latest version.

Components({
      // allow auto load markdown components under `./src/components/`
      extensions: ['vue', 'md'],

      // allow auto import and register components used in markdown
      include: [/\.vue$/, /\.vue\?vue/, /\.md$/],

      // custom resolvers
      resolvers: [
        // auto import icons
        // https://github.com/antfu/unplugin-icons
        IconsResolver({
          componentPrefix: '',
          // enabledCollections: ['carbon']
        }),
        // https://github.com/antfu/unplugin-vue-components/issues/202
        AntDesignVueResolver({  
          cjs: false
        }),
      ],

      dts: 'src/components.d.ts',
    }),

error:

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
(node:186362) UnhandledPromiseRejectionWarning: Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/home/project/node_modules/ant-design-vue/es' is not supported resolving ES modules imported from /home/project/.vite-ssg-temp/main.mjs
Did you mean to import ant-design-vue@3.0.0-beta.4_ae87cbba5ec93a01f3fe1197df446ca3/node_modules/ant-design-vue/es/index.js?
    at new NodeError (internal/errors.js:322:7)
    at finalizeResolution (internal/modules/esm/resolve.js:304:17)
    at moduleResolve (internal/modules/esm/resolve.js:731:10)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:842:11)
    at Loader.resolve (internal/modules/esm/loader.js:89:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
    at link (internal/modules/esm/module_job.js:75:36)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:186362) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 17)
(node:186362) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

npm run dev works fine, using template from https://github.com/antfu/vitesse

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:12

github_iconTop GitHub Comments

2reactions
KeremKoksalcommented, Feb 18, 2022

I had the same problem with primevue and vitesse

Vitesse also uses vite-ssg. Setting format to cjs in ssgOptions fixed my issue.

vite.config.ts:

...

  ssgOptions: {
    script: 'async',
    formatting: 'minify',
    format: 'cjs'
  },

...

Also, I have updated all the packages.

...
    "unplugin-vue-components": "^0.17.18",
    "vite": "^2.8.4",
    "vite-plugin-inspect": "^0.3.14",
    "vite-plugin-md": "^0.11.8",
    "vite-plugin-pages": "^0.20.2",
    "vite-plugin-pwa": "^0.11.13",
    "vite-plugin-vue-layouts": "^0.6.0",
    "vite-plugin-windicss": "^1.7.1",
    "vite-ssg": "^0.17.10",
...
2reactions
liangyuanzucommented, Jan 13, 2022

I also have this problem

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/jason_liang/Documents/Code/suiji/suiji-webapp/webapp/node_modules/ant-design-vue/es/locale/en_US' imported from /Users/jason_liang/Documents/Code/suiji/suiji-webapp/webapp/.vite-ssg-temp/main.mjs
Did you mean to import ant-design-vue@3.0.0-beta.7_ae87cbba5ec93a01f3fe1197df446ca3/node_modules/ant-design-vue/es/locale/en_US.js?
    at new NodeError (node:internal/errors:371:5)
    at finalizeResolution (node:internal/modules/esm/resolve:416:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1044:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}
 ELIFECYCLE  Command failed with exit code 1.
 ELIFECYCLE  Command failed with exit code 1.

npm run dev works fine, using template from https://github.com/antfu/vitesse

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Directory import is not supported resolving ES modules' with ...
With ES6 modules you can not (yet?) import directories. Your import should look like this: import database from "./database/index.js".
Read more >
@nextcloud/vue - npm
This repo contains the various Vue.js components that Nextcloud uses for its internal design and structure. It provides standardized UI elements for building...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found