-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: import_url.URL is not a constructor #10410
Comments
This comment is describing a similar (or exactly the same) error: #10365 (comment) |
I got exactly the same problem with the same config, upgrading to vite 3.1.5 or latest and the bug appears, so was staying in 3.1.4 but you’re fix is working for me, thank you ! My dependencies : {
"dependencies": {
"vue": "3.2.40"
},
"devDependencies": {
"@rushstack/eslint-patch": "1.2.0",
"@types/node": "18.8.0",
"@vitejs/plugin-vue": "3.1.2",
"@vue/eslint-config-prettier": "7.0.0",
"@vue/eslint-config-typescript": "11.0.2",
"@vue/tsconfig": "0.1.3",
"axios": "1.1.2",
"eslint": "8.25.0",
"eslint-plugin-vue": "9.6.0",
"npm-run-all": "4.1.5",
"prettier": "2.7.1",
"rollup-plugin-visualizer": "5.8.2",
"typescript": "4.8.4",
"vite": "3.1.4",
"vue-tsc": "1.0.3"
}
} My import { fileURLToPath, URL } from "url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { visualizer } from "rollup-plugin-visualizer";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), visualizer()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
server: {
port: 3000,
},
}); |
Can confirm, this resolves the issue but shouldn't be needed |
Same for me @adamdehaven
This worked for me 👍 |
Describe the bug
When trying to upgrade from
3.1.4
to a newer version (does not matter which one), I'm getting an error when running any of the following scripts:vite
vite build
vitest
cypress open --component
start-storybook
The error:
TypeError: import_url.URL is not a constructor
This happens for projects that use Storybook.
Fix
If I change the import syntax in my
vite.config.ts
from:to
the error no longer shows up.
I have no clue why this fixes the problem, just that it does. Got the idea from exploring the code changes in #10254
Reproduction
https://stackblitz.com/edit/vitejs-vite-udpzay?file=vite.config.ts
Steps to reproduce
vite.config.ts
file:npx storybook init
html
as your framework)yarn dev
and observe the errorSystem Info
Used Package Manager
yarn
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: