vite安装路由启动报错。

vite安装路由后启动该报错如下

[vite] Optimizable dependencies detected:
router, vue

[vite] Dep optimization failed with error:
Could not load url (imported by node_modules/parseurl/index.js): ENOENT: no such file or directory, open 'D:\learning\学习案例集合\vue\vue作业\homework\url'
[Error: Could not load url (imported by node_modules/parseurl/index.js): ENOENT: no such file or directory, open 'D:\learning\学习案例集合\vue\vue作业\homework\url'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'D:\\learning\\学习案例集合\\vue\\vue作业\\homework\\url',
  watchFiles: [
    'D:\\learning\\学习案例集合\\vue\\vue作业\\homework\\node_modules\\router\\index.js'

查看package.json:

"dependencies": {
    "router": "^1.3.7",
    "vue": "^3.0.4"
  },
  "devDependencies": {
    "@vue/compiler-sfc": "^3.0.4",
    "vite": "^1.0.0-rc.13",
    "vue-router": "^4.0.13"
  }

解决方案:

查看package.json中:发现运行依赖是3.x版本路由,开发依赖是4.x版本,说明安装了两次,且版本不同,vite项目用vue3,需要4.x路由

手动修改如下,重新npm i :

"dependencies": {
    "vue-router": "^4.0.13",
    "vue": "^3.0.4"
  },
  "devDependencies": {
    "@vue/compiler-sfc": "^3.0.4",
    "vite": "^1.0.0-rc.13",
    "vue-router": "^4.0.13"
  }

done!!!

你可能感兴趣的:(bug,vue.js,前端,javascript)