1. 程式人生 > 實用技巧 >Module build failed (from ./node_modules/babel-loader/lib/index.js):

Module build failed (from ./node_modules/babel-loader/lib/index.js):

 ERROR  Failed to compile with 1 errors                                                               friendly-errors 09:48:15  


 ERROR  in ./.nuxt/client.js                                                                          friendly-errors 09:48:15  

Module build failed (from ./node_modules/babel-loader/lib/index.js):                                  friendly-errors 09:48:15  
Error: [BABEL] D:\project\myself\front_parent\vs2020\vue
-front-1010\vue-front-1010\.nuxt\client.js: Cannot find module '@babel/compat-data/corejs3-shipped-proposals' Require stack: - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@babel\preset-env\lib\polyfills\corejs3\usage-plugin.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@babel\preset-env\lib\index.js
- D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@nuxt\babel-preset-app\src\index.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@babel\core\lib\config\files\plugins.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@babel\core\lib\config\files\index.js
- D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@babel\core\lib\index.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\babel-loader\lib\index.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\loader-runner\lib\loadLoader.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\loader-runner\lib\LoaderRunner.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\webpack\lib\NormalModule.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\webpack\lib\NormalModuleFactory.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\webpack\lib\Compiler.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\webpack\lib\webpack.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@nuxt\webpack\dist\webpack.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@nuxt\cli\dist\cli-command.js - D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\nuxt\bin\nuxt.js (While processing: "D:\\project\\myself\\front_parent\\vs2020\\vue-front-1010\\vue-front-1010\\node_modules\\@nuxt\\babel-preset-app\\src\\index.js") at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15) at Function.Module._load (internal/modules/cjs/loader.js:842:27) at Module.require (internal/modules/cjs/loader.js:1026:19) at require (internal/modules/cjs/helpers.js:72:18) at Object.<anonymous> (D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@babel\preset-env\lib\polyfills\corejs3\usage-plugin.js:10:55) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Module.require (internal/modules/cjs/loader.js:1026:19) at require (internal/modules/cjs/helpers.js:72:18) at Object.<anonymous> (D:\project\myself\front_parent\vs2020\vue-front-1010\vue-front-1010\node_modules\@babel\preset-env\lib\index.js:29:44) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) friendly-errors 09:48:15 @ multi eventsource-polyfill webpack-hot-middleware/client?reload=true&timeout=30000&ansiColors=&overlayStyles=&name=client&path=/__webpack_hmr/client ./.nuxt/client.js

在vue專案啟動時,出現如上所示的錯誤,解決方法,在整合終端執行如下程式碼:

npm install @babel/core @babel/preset-env

出現如上所示結果,按照提示,輸入命令:npm audit fix

npm audit fix

然後再輸入:npm run dev即可。