vite run using v0.22.1 gives "Cannot use 'import.meta' outside a module"
See original GitHub issueDescribe the bug
Hi, When compiling the vite project after updating to v0.22.1 (v0.22.0 works fine), I am getting the following error:
SyntaxError: Cannot use 'import.meta' outside a module
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object._require.extensions.<computed> [as .js] (.../vite/dist/node/chunks/dep-71eb12cb.js:62910:17)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (C:\...\unplugin-vue-components\dist\vite.js:3:24)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
The Vite version is: 3.0.4. Let me know if I can provide anything else to help debug.
Reproduction
Use vite with v0.22.1
System Info
System:
OS: Windows 10 10.0.19044
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 15.68 GB / 31.92 GB
Binaries:
Node: 14.20.0 - C:\Program Files\nodejs\node.EXE
npm: 8.5.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.77)
Internet Explorer: 11.0.19041.1566
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- The provided reproduction is a minimal reproducible of the bug.
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:9
Top Results From Across the Web
vite.config.js - Cannot use import statement outside a module
When I run npm run dev to run Vite, I always get the error: SyntaxError: Cannot use import statement outside a module when...
Read more >Cannot use import.meta outside a module. Vite testing [closed]
I'm using vite and jest for testing. When i run my tests i get this error. This is my .babelrc file babelrc. and...
Read more >Features | Vite
The above will throw an error in the browser. Vite will detect such bare module imports in all served source files and perform...
Read more >vite exports is not defined | The AI Search Engine You Control
Describe the bug. error: exports is not defined when using ViteDevServer.ssrLoadModule with the following setups: package.json.
Read more >vite - npm
Start using vite in your project by running `npm i vite`. ... For a module to self-accept, use import.meta.hot.accept :.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No need to downgrade, you can temporarily add
"type": "module"
to package.json to fix the problemThank you for the fix 🙏