用vue-clie脚手架搭建完vue3工程,执行npm run serve,会报一下错误。
Error: Cannot find module 'fork-ts-checker-webpack-plugin-v5'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at api.chainWebpack.config (E:\vueDemo\hello-world2\node_modules\@vue\cli-plugin-typescript\index.js:89:16)
at webpackChainFns.forEach.fn (E:\vueDemo\hello-world2\node_modules\@vue\cli-service\lib\Service.js:236:40)
at Array.forEach (<anonymous>)
at Service.resolveChainableWebpackConfig (E:\vueDemo\hello-world2\node_modules\@vue\cli-service\lib\Service.js:236:26)
at Service.resolveWebpackConfig (E:\vueDemo\hello-world2\node_modules\@vue\cli-service\lib\Service.js:240:48)
at PluginAPI.resolveWebpackConfig (E:\vueDemo\hello-world2\node_modules\@vue\cli-service\lib\PluginAPI.js:132:25)
at serve (E:\vueDemo\hello-world2\node_modules\@vue\cli-service\lib\commands\serve.js:75:31)
at Service.run (E:\vueDemo\hello-world2\node_modules\@vue\cli-service\lib\Service.js:230:12)
at Object.<anonymous> (E:\vueDemo\hello-world2\node_modules\@vue\cli-service\bin\vue-cli-service.js:36:9)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
解决方案:
npm i fork-ts-checker-webpack-plugin,不要带后面-v5
猜想:可能作者在内部给fork-ts-checker-webpack-plugin起了个别名fork-ts-checker-webpack-plugin-v5,所以只需要安装fork-ts-checker-webpack-plugin即可