Angular项目执行npm start启动失败的问题求助
Angular项目执行npm start启动失败的问题求助
大家好,我现在碰到了Angular项目启动的棘手问题,试了几个方法都没搞定,想请教下社区的大佬们。
问题场景
我先通过npm install完成了项目依赖的安装,但执行npm start命令(实际对应脚本是ng serve)时,控制台抛出了错误导致启动失败。
完整错误日志
tcm@0.0.0 start ng serve Workspace extension with invalid name (defaultProject) found. Option "browserTarget" is deprecated: Use 'buildTarget' instead. **************************************************************************************** This is a simple server for use in testing or debugging Angular applications locally. It hasn't been reviewed for security issues. DON'T USE IT FOR PRODUCTION! **************************************************************************************** file:///D:/Halo_Flights/haloflights_new/haloflights_new/node_modules/@angular/compiler-cli/bundles/chunk-ILV5JRA3.js:3427 import { ArrowFunctionExpr, LiteralArrayExpr, LiteralExpr as LiteralExpr2, literalMap, WrappedNodeExpr as WrappedNodeExpr3 } from "@angular/compiler"; ^^^^^^^^^^^^^^^^^ SyntaxError: Named export 'ArrowFunctionExpr' not found. The requested module '@angular/compiler' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from '@angular/compiler'; const { ArrowFunctionExpr, LiteralArrayExpr, LiteralExpr: LiteralExpr2, literalMap, WrappedNodeExpr: WrappedNodeExpr3 } = pkg; at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21) at async ModuleJob.run (node:internal/modules/esm/module_job:214:5) at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) at async importModuleDynamicallyWrapper (node:internal/vm/module:431:15) at async readTsconfig (D:\Halo_Flights\haloflights_new\haloflights_new\node_modules\@angular-devkit\build-angular\src\utils\read-tsconfig.js:48:54) at async configureI18nBuild (D:\Halo_Flights\haloflights_new\haloflights_new\node_modules\@angular-devkit\build-angular\src\utils\i18n-options.js:125:22) at async generateI18nBrowserWebpackConfigFromContext (D:\Halo_Flights\haloflights_new\haloflights_new\node_modules\@angular-devkit\build-angular\src\utils\webpack-browser-config.js:66:36) at async setup (D:\Halo_Flights\haloflights_new\haloflights_new\node_modules\@angular-devkit\build-angular\src\builders\dev-server\webpack-server.js:96:34) Node.js v20.10.0
已尝试的解决方案
- 更新项目依赖包:执行
npm update - 删除
package-lock.json文件后,重新执行npm install重装依赖
但以上操作都没有解决问题,错误依然和上面的日志一致。有没有大佬能帮忙分析下这个错误的原因,以及可能的解决办法?谢谢大家了!
备注:内容来源于stack exchange,提问作者amry saffan
相关产品推荐
相关产品推荐

