npm create vite@latest prompts syntax errors with internal module imports #14789
Replies: 2 comments 1 reply
-
does it still happen if you uninstall vite globally? try uninstalling and see. don't have access to a windows machine unfortunately |
Beta Was this translation helpful? Give feedback.
-
Stumbled upon this via Google and wanted to help out future people: Given your user path, it seems likely you're on Windows. I seeing the same, and while I haven't dug into it in the depths, a fairly old version of Node was making its way into the executable path before Nodist. You can see this if you run the following:
In specific "C:\Program Files (x86)\Nodist\bin" was (correctly) on my path, but had a very outdated version of node next to it that didn't get removed with an uninstall. I'd recommend looking at your system path and environment variables to try and trace down the oldest version if you see it. EDIT: Update. It seems that nodist, when installed with chocolatey as I did, will default to installing 11. You can do |
Beta Was this translation helpful? Give feedback.
-
While trying to install vite build using npm create vite@latest, after installing vite globally. I keep getting an error
SyntaxError: Cannot use import statement outside a module
.This is the full error statement. ```C:\Users\Travelmania\AppData\Local\npm-cache_npx\53b8fd318f0d6c47\node_modules\create-vite\index.js:3
import './dist/index.mjs'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Module._compile (internal/modules/cjs/loader.js:891:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
I have tried everything I know, I added
"type": "module"``` to the the package.json, nothing seems to work.I then forked a vite template from github, npm install works, but when I run dev or start, I get this ES6 incompatibility error as well.
Beta Was this translation helpful? Give feedback.
All reactions