Problem importing vue-router & vuex from v0.6.0 onward
The Error
Error on command line console:
[vite] Error while resolving node_modules with id "%5C@modules%5Cvue-router%5Cdist%5Cvue-router.esm-bundler.js":
{ Error: Cannot find module '%5C@modules%5Cvue-router%5Cdist%5Cvue-router.esm-bundler.js'
How to create the problem
- follow steps as per normal to create vite project using npx
- install vite 0.6.0 (from 0.5.1)
- install vua-router@4.0.0-alpha.8
- add follwing to index.html file
import { createRouter, createWebHistory } from 'vue-router'
- npm run dev and problem will appear when you navigate to the page
This is because the dist file of vue-router
referenced a source map but didn't include it in the published package.
Closing since it's a vue-router
issue.
/cc @posva
I just tried again, it is still happening. Not just to vue-router, but also vuex...
Error: Cannot find module '%5C@modules%5Cvuex%5Cdist%5Cvuex.esm-bundler.js'
Error: Cannot find module '%5C@modules%5Cvue-router%5Cdist%5Cvue-router.esm-bundler.js'
The path looks wierd
This is causing the exception to be thrown
in the vite distribution, serverPluginModules.js file
console.log('cc')
const modulePath = resolve_from_1.default(root, id);
console.log('dd', modulePath)
The value of id is... %5C@modules%5Cvuex%5Cdist%5Cvuex.esm-bundler.js
Going up the code (not down)
app.use(async (ctx, next) => {
if (!moduleRE.test(ctx.path)) {
return next();
}
const id = ctx.path.replace(moduleRE, '');
console.log('aa', moduleRE, id, ctx.path)
The console error is...
aa /^\/@modules\// vue /@modules/vue
(node:3832) ExperimentalWarning: The fs.promises API is experimental
aa /^\/@modules\// vuex /@modules/vuex
aa /^\/@modules\// %5C@modules%5Cvuex%5Cdist%5Cvuex.esm-bundler.js /@modules/%5C@modules%5Cvuex%5Cdist%5Cvuex.esm-bundler.js
aa /^\/@modules\// vue-router /@modules/vue-router
[vite] Error while resolving node_modules with id "%5C@modules%5Cvuex%5Cdist%5Cvuex.esm-bundler.js":
{ Error: Cannot find module '%5C@modules%5Cvuex%5Cdist%5Cvuex.esm-bundler.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at resolveFileName (C:\Users\user\test\vite-eg\node_modules\resolve-from\index.js:29:39)
at resolveFrom (C:\Users\user\test\vite-eg\node_modules\resolve-from\index.js:43:9)
at Object.module.exports [as default] (C:\Users\user\test\vite-eg\node_modules\resolve-from\index.js:46:47)
at app.use (C:\Users\user\test\vite-eg\node_modules\vite\dist\serverPluginModules.js:148:54) code: 'MODULE_NOT_FOUND' }
aa /^\/@modules\// %5C@modules%5Cvue-router%5Cdist%5Cvue-router.esm-bundler.js /@modules/%5C@modules%5Cvue-router%5Cdist%5Cvue-router.esm-bundler.js
[vite] Error while resolving node_modules with id "%5C@modules%5Cvue-router%5Cdist%5Cvue-router.esm-bundler.js":
{ Error: Cannot find module '%5C@modules%5Cvue-router%5Cdist%5Cvue-router.esm-bundler.js'