.net core angular 5找不到模块“popper.js”

时间:2018-02-20 22:07:49

标签: bootstrap-4 asp.net-core-2.0 angular5 popper.js

我一直在寻找一个没有运气的解决方案,没有人似乎知道如何正确导入popper.js到.net核心中的角度5项目,我正在使用Visual Studio 2017,这发生在更新后包,我知道这是与bootstrap 4相关的东西,这是我的package.json:

  {
  "name": "Monitor",
  "private": true,
  "version": "0.0.0",
  "scripts": {
    "test": "karma start ClientApp/test/karma.conf.js"
  },
  "devDependencies": {
    "@angular/animations": "^5.2.5",
    "@angular/common": "^5.2.5",
    "@angular/compiler": "^5.2.5",
    "@angular/compiler-cli": "^5.2.5",
    "@angular/core": "^5.2.5",
    "@angular/forms": "5.2.5",
    "@angular/http": "5.2.5",
    "@angular/platform-browser": "5.2.5",
    "@angular/platform-browser-dynamic": "5.2.5",
    "@angular/platform-server": "5.2.5",
    "@angular/router": "5.2.5",
    "@ngtools/webpack": "1.10.0",
    "@types/chai": "4.1.2",
    "@types/jasmine": "2.8.6",
    "@types/webpack-env": "1.13.5",
    "angular2-router-loader": "0.3.5",
    "angular2-template-loader": "0.6.2",
    "aspnet-prerendering": "^3.0.1",
    "aspnet-webpack": "^2.0.1",
    "awesome-typescript-loader": "3.4.1",
    "bootstrap": "4.0.0",
    "chai": "4.1.2",
    "css": "2.2.1",
    "css-loader": "0.28.9",
    "es6-shim": "0.35.3",
    "event-source-polyfill": "0.0.12",
    "expose-loader": "0.7.4",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.7",
    "html-loader": "0.5.5",
    "isomorphic-fetch": "2.2.1",
    "jasmine-core": "2.99.1",
    "jquery": "^3.3.1",
    "json-loader": "0.5.7",
    "karma": "2.0.0",
    "karma-chai": "0.1.0",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.1",
    "karma-webpack": "2.0.9",
    "preboot": "6.0.0-beta.2",
    "raw-loader": "0.5.1",
    "reflect-metadata": "^0.1.12",
    "rxjs": "5.5.6",
    "style-loader": "0.20.2",
    "to-string-loader": "1.1.5",
    "typescript": "2.7.2",
    "url-loader": "0.6.2",
    "webpack": "3.11.0",
    "webpack-hot-middleware": "2.21.0",
    "webpack-merge": "4.1.1",
    "zone.js": "0.8.20"
  },
  "dependencies": {
    "popper.js": "^1.12.9"
  }
}

注意popper.js依赖关系,所以它是安装的,它应该去那里还是其他地方?

还尝试过: 在bootstrap导入之前,在boot.browser.ts文件中导入'popper.js'。

我不知道在哪里看,似乎没有人对此有正确答案。

提前致谢。

编辑: 我按照本教程使用带有.net core 2的VS2017创建和更新角度应用程序 https://www.codeproject.com/Articles/1221503/Angular-and-NET-Core-with-Visual-Studio

1 个答案:

答案 0 :(得分:0)

似乎我解决了这个问题,webpack.config.vendor.js文件必须用popper.js重新绑定:

const nonTreeShakableModules = [
    'bootstrap',
    'bootstrap/dist/css/bootstrap.css',
    'es6-promise',
    'es6-shim',
    'event-source-polyfill',
    'jquery',
];

并使用popper.js:

const nonTreeShakableModules = [
    'popper.js/dist/umd/popper.js',
    'bootstrap',
    'bootstrap/dist/css/bootstrap.css',
    'es6-promise',
    'es6-shim',
    'event-source-polyfill',
    'jquery',
];

此外,您需要在以power-shell身份运行此命令之前关闭Visual Studio:

  

webpack --config webpack.config.vendor.js

瞧,瞧!它再次起作用。