Subscribe on changes!

Problem importing vue-router & vuex from v0.6.0 onward

avatar
Apr 29th 2020

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

  1. follow steps as per normal to create vite project using npx
  2. install vite 0.6.0 (from 0.5.1)
  3. install vua-router@4.0.0-alpha.8
  4. add follwing to index.html file
import { createRouter, createWebHistory } from 'vue-router'
  1. npm run dev and problem will appear when you navigate to the page
avatar
Apr 29th 2020

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

avatar
Apr 29th 2020

I published a new version without the sourcemaps

avatar
Apr 30th 2020

that was quiclk. thanks!

avatar
Apr 30th 2020

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

avatar
Apr 30th 2020

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

avatar
Apr 30th 2020

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'
avatar
Apr 30th 2020

Are you on Windows? Nvm, it must be a Windows path problem.

avatar
Apr 30th 2020

Yes, I am on windows 10...

avatar
Sep 13th 2020

getting the same problem and I'm on a mac

avatar
Nov 18th 2020

Any updates on this issue?