Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

package.json type module #20

Closed
jrson83 opened this issue May 1, 2022 · 1 comment
Closed

package.json type module #20

jrson83 opened this issue May 1, 2022 · 1 comment

Comments

@jrson83
Copy link

jrson83 commented May 1, 2022

When using type: module in my projects package.json, I get the following error:

 npm run dev

> vite-plugin-glob-test@0.0.0 dev
> vite

failed to load config from D:\______mono\jrson.de\vite-plugin-glob-test\vite.config.ts
error when starting dev server:
file:///D:/______mono/jrson.de/vite-plugin-glob-test/node_modules/vite-plugin-glob/dist/index.mjs:1
import { scan, isMatch } from 'micromatch';
               ^^^^^^^
SyntaxError: Named export 'isMatch' not found. The requested module 'micromatch' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'micromatch';
const { scan, isMatch } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async loadConfigFromFile (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\chunks\dep-3397b401.js:61680:31)
    at async resolveConfig (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\chunks\dep-3397b401.js:61224:28)
    at async createServer (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\chunks\dep-3397b401.js:59636:20)
    at async CAC.<anonymous> (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\cli.js:688:24)

I created a minimal setup for reproduction with create vite & preact-ts.

https://github.com/jrson83/vite-plugin-glob-module-issue

@antfu antfu closed this as completed in c435b97 May 3, 2022
@jrson83
Copy link
Author

jrson83 commented May 3, 2022

Thanks!

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

No branches or pull requests

1 participant