vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

Relative module was not found #6636

Closed thep0y closed 3 years ago

thep0y commented 3 years ago

Version

4.5.13

Reproduction link

https://github.com/thep0y/vue-ts-issue

Environment info

System:
    OS: Linux 5.12 Deepin 20.2.2 20.2.2
    CPU: (8) x64 Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
  Binaries:
    Node: 14.17.5 - /usr/local/node/bin/node
    Yarn: 1.22.11 - /usr/local/node/bin/yarn
    npm: 6.14.14 - /usr/local/node/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1 
    @vue/babel-helper-vue-transform-on:  1.0.2 
    @vue/babel-plugin-jsx:  1.0.6 
    @vue/babel-plugin-transform-vue-jsx:  1.2.1 
    @vue/babel-preset-app:  4.5.13 
    @vue/babel-preset-jsx:  1.2.4 
    @vue/babel-sugar-composition-api-inject-h:  1.2.1 
    @vue/babel-sugar-composition-api-render-instance:  1.2.4 
    @vue/babel-sugar-functional-vue:  1.2.2 
    @vue/babel-sugar-inject-h:  1.2.2 
    @vue/babel-sugar-v-model:  1.2.3 
    @vue/babel-sugar-v-on:  1.2.3 
    @vue/cli-overlay:  4.5.13 
    @vue/cli-plugin-babel: ~4.5.0 => 4.5.13 
    @vue/cli-plugin-eslint: ~4.5.0 => 4.5.13 
    @vue/cli-plugin-router:  4.5.13 
    @vue/cli-plugin-typescript: ~4.5.0 => 4.5.13 
    @vue/cli-plugin-vuex:  4.5.13 
    @vue/cli-service: ~4.5.0 => 4.5.13 
    @vue/cli-shared-utils:  4.5.13 
    @vue/compiler-core:  3.2.2 
    @vue/compiler-dom:  3.2.2 
    @vue/compiler-sfc: ^3.0.0 => 3.2.2 
    @vue/compiler-ssr:  3.2.2 
    @vue/component-compiler-utils:  3.2.2 
    @vue/devtools-api:  6.0.0-beta.15 
    @vue/eslint-config-prettier: ^6.0.0 => 6.0.0 
    @vue/eslint-config-typescript: ^7.0.0 => 7.0.0 
    @vue/preload-webpack-plugin:  1.1.2 
    @vue/reactivity:  3.2.2 
    @vue/runtime-core:  3.2.2 
    @vue/runtime-dom:  3.2.2 
    @vue/shared:  3.2.2 
    @vue/web-component-wrapper:  1.3.0 
    eslint-plugin-vue: ^7.0.0 => 7.16.0 
    typescript: ~4.1.5 => 4.1.6 
    vue: ^3.0.0 => 3.2.2 
    vue-class-component: ^8.0.0-0 => 8.0.0-rc.1 
    vue-eslint-parser:  7.10.0 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.9.8 (16.5.0)
    vue-router: 4 => 4.0.11 
    vue-style-loader:  4.1.3 
    vue-template-es2015-compiler:  1.9.1 
  npmGlobalPackages:
    @vue/cli: 4.5.13

Steps to reproduce

  1. yarn
  2. yarn serve

What is expected?

main.ts can imported router normally.

What is actually happening?

 ERROR  Failed to compile with 1 error                                                     下午12:38:02

This relative module was not found:

* ./router in ./src/main.ts
Issues checking in progress...
No issues found.
haoqunjiang commented 3 years ago

Do not overwrite the resolve object. Use this configuration instead:

// vue.config.js
module.exports = {
  runtimeCompiler: true
}