我没有找到关于此主题的问题,但是,花了一些时间之后,我仍然坚持这一点。
我正在与以下项目一起工作:
此package.json
{
"devDependencies": {
"babel-loader": "^7.1.4",
"babel-plugin-transform-es2015-destructuring": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"bootstrap-sass": "^3.3.7",
"browser-sync": "^2.23.6",
"browser-sync-webpack-plugin": "^2.2.2",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"expose-loader": "^0.7.5",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"fast-sass-loader": "^1.4.1",
"file-loader": "^1.1.11",
"hard-source-webpack-plugin": "^0.6.4",
"jquery-bem-utils": "^0.0.8",
"node-sass": "^4.7.2",
"path": "^0.12.7",
"postcss-cssnext": "^3.1.0",
"postcss-csso": "^3.0.0",
"postcss-loader": "^2.1.2",
"purify-css": "^1.2.5",
"purifycss-webpack": "^0.7.0",
"sass-loader": "^6.0.6",
"style-loader": "^0.20.3",
"svgo": "^1.0.5",
"uglifyjs-webpack-plugin": "^1.2.4",
"url-loader": "^1.0.1",
"webpack": "^4.1.1",
"webpack-cli": "^3.0.0",
"webpack-dev-server": "^3.1.1",
"webpack-spritesmith": "^0.4.0"
},
...
"dependencies": {
"babel-core": "6",
"bootstrap": "^4.1.0",
"bootstrap-growl-ifightcrime": "^1.1.0",
"bootstrap-slider": "^10.0.0",
"bootstrap-tabcollapse": "^0.2.6",
"caniuse-lite": "^1.0.30000697",
"jquery": "^3.3.1",
"photoswipe": "^4.1.2",
"popper.js": "^1.12.9",
"sidr": "^2.2.1",
"slick-carousel": "^1.8.1",
"twbs-pagination": "^1.4.1"
}
}
此webpack.config.js:
new webpack.ProvidePlugin({
'$': 'jquery',
'jQuery': 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
}),
如果我移除了node_modules/
,然后执行了yarn install && yarn start
,则一切按预期进行。
如果我停止yarn start
并重新运行它,则会出现此错误:
ReferenceError: undefinedPopper is not defined
会导致webpack://app/./node_modules/popper.js/dist/esm/popper.js?:2534:30
=> __webpack_exports__["default"] = (undefinedPopper);
我不知道我在做什么错,知道吗?