我在这个问题上卡了好几天了。我做了一些研究,但都无济于事。每次在终端运行 "ng serve" 后,都会报错:
> ./node_modules/@angular/router/fesm2020/router.mjs - Error: Module build failed (from ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js):
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '\node_modules\@angular\compiler-cli\node_modules\@babel\core\' imported from \node_modules\@angular\compiler-cli\bundles\linker\babel\index.js
Did you mean to import @babel/core/lib/index.js?
at legacyMainResolve (internal/modules/esm/resolve.js:225:9)
at packageResolve (internal/modules/esm/resolve.js:648:14)
at moduleResolve (internal/modules/esm/resolve.js:696:18)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)
at Loader.resolve (internal/modules/esm/loader.js:88:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:241:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:56:40)
at link (internal/modules/esm/module_job.js:55:36)
我的 package.json 文件如下:
"devDependencies": {
"@angular-devkit/build-angular": "^13.0.2",
"@angular/cli": "^13.0.2",
"@angular/compiler-cli": "~13.0.1",
"@babel/cli": "^7.16.8",
"@babel/core": "^7.16.7",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.8",
"@types/file-saver": "^2.0.3",
"@types/jasmine": "~3.8.2",
"@types/node": "^16.7.10",
"@types/xlsx": "0.0.36",
"babel-loader": "^8.2.3",
"jasmine-core": "~3.8.0",
"karma": "~6.3.4",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.4.4",
"webpack": "^5.66.0"}
我的.babelrc文件如下:
{"presets": ["@babel/preset-env"]}
你能给我一些建议吗?谢谢!