【问题标题】:Module not found : error : Can't resolve 'ngx-bootstrap'找不到模块:错误:无法解析“ngx-bootstrap”
【发布时间】:2020-10-05 19:15:59
【问题描述】:

我在将我的 Angular 版本升级到 v8 后尝试构建我的项目,当我编译我的项目时出现以下错误,

1>Module not found : error : Can't resolve 'ngx-bootstrap' in 'C:\Users\can.pahali\source\WestCore.MvcSpa-Upgrade'
1>     @ dll vendor vendor[9]
1>    Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js!node_modules/bootstrap/dist/css/bootstrap.css:
1>        Entrypoint mini-css-extract-plugin = *
1>    Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js!node_modules/font-awesome/css/font-awesome.css:
1>        Entrypoint mini-css-extract-plugin = *
1>    Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js!node_modules/startbootstrap-sb-admin-2/dist/css/sb-admin-2.css:
1>        Entrypoint mini-css-extract-plugin = *
1>C:\Users\can.pahali\source\WestCore.MvcSpa-Upgrade\WestCore.MvcSpa.csproj(156,5): error MSB3073: The command "node --max-old-space-size=4096 node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" exited with code 2.
1>Done building project "WestCore.MvcSpa.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

我的ng v 输出在这里,

Angular CLI: 8.3.27
Node: 13.5.0
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.8
@angular-devkit/build-angular     0.901.8
@angular-devkit/build-optimizer   0.901.8
@angular-devkit/build-webpack     0.901.8
@angular-devkit/core              7.1.2
@angular-devkit/schematics        8.3.27
@angular/cdk                      8.2.3
@angular/cli                      8.3.27
@angular/http                     7.2.16
@ngtools/webpack                  7.1.2
@nguniversal/aspnetcore-engine    7.1.1
@nguniversal/common               7.1.1
@schematics/angular               8.3.27
@schematics/update                0.803.27
rxjs                              6.5.5
typescript                        3.5.3
webpack                           4.43.0

我也检查了我的 ngx-bootstrap 导入,它们看起来都很好,没有错误。如果需要,我还可以共享我的 package.json 文件。 我真的被困在这里了,任何帮助都可以维持我的生命,谢谢。

最好的问候。

【问题讨论】:

  • 检查你的node_modules 文件夹,如果 ngx-bootstrap 真的存在的话
  • 当模块有时被破坏时,删除文件夹 ngx-bootstrap 并重新运行 npm 安装,有时它很神奇。
  • @Nico 是的,我检查了,node_modules 包含 ngx-bootstrap 文件夹并重新运行 npm i。但是还是一样的:(
  • 运行npm link 然后npm install 工作?它应该同步全局和本地 node_modules 文件夹,也许你命令搜索全局位置
  • 您可以尝试卸载然后重新安装软件包吗? npm uninstall ngx-bootstrap 然后 npm install ngx-bootstrap

标签: angular webpack angular8 ngx-bootstrap


【解决方案1】:

我想我在这里找到了问题,我使用的是ngx-bootstrap@5.6.2,我降级了版本ngx-bootstrap@5.5.0,问题就消失了。我的 Angular 8 版本一定有问题,与 >ngx-bootstrap@5.5.0 不兼容。我也会在github上报告这个问题。

最好的问候。

【讨论】:

  • 我在 Angular 7.1.2 中遇到了同样的问题你找到 ngx-bootstrap@5.6.2 的解决方案了吗?
【解决方案2】:

对我来说,删除node_modules 中的ngx-bootstrap 文件夹,然后运行npm inpm audit fix 即可解决问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-17
    • 2019-04-26
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 2020-07-19
    • 2020-12-15
    相关资源
    最近更新 更多