SyntaxError: Cannot use import statement outside a module
See original GitHub issue⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.
- Read the docs.
- Use Vite >=2.0. (1.x is no longer supported)
- If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.
Describe the bug
npm run dev failed to start
Reproduction
System Info
vite
version: 2.0.0-beta.12- Operating System: window 10
- Node version: 14.4.0
- Package manager (npm/yarn/pnpm) and version: npm
Logs (Optional if provided reproduction)
PS C:\code\demo\vite-project> npm run dev
vite-project@0.0.0 dev C:\code\demo\vite-project vite
failed to load config from /code/demo/vite-project/vite.config.js error when starting dev server: C:\code\demo\vite-project\vite.config.js:1 import vue from ‘@vitejs/plugin-vue’ ^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1116:16)
at Module._compile (internal/modules/cjs/loader.js:1164:27)
at Module._extensions…js (internal/modules/cjs/loader.js:1220:10)
at Object.require.extensions.<computed> [as .js] (C:\code\demo\vite-project\node_modules_vite@2.0.0-beta.22@vite\dist\node\chunks\dep-30d01443.js:46937:13)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at loadConfigFromBundledFile (C:\code\demo\vite-project\node_modules_vite@2.0.0-beta.22@vite\dist\node\chunks\dep-30d01443.js:46941:17)
at loadConfigFromFile (C:\code\demo\vite-project\node_modules_vite@2.0.0-beta.22@vite\dist\node\chunks\dep-30d01443.js:46888:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vite-project@0.0.0 dev: vite
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vite-project@0.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\sl\AppData\Roaming\npm-cache_logs\2021-01-12T02_23_42_087Z-debug.log
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@Akryum Try to just renaming your
vite.config.js
tovite.config.ts
.I don’t understand 🙇