![](/img/trans.png)
[英]ERROR in Entry module not found: Error: Can't resolve 'babel-loader'
[英]Module not found: Error: Can't resolve 'babel-loader'
只是我將我的網絡包從 2.x 升級到 4.x。 通過執行 npm install 我收到以下錯誤
Module not found: Error: Can't resolve 'babel-loader'
在github 線程之后,我在 webpack.config.json 中添加了以下幾行
resolveLoader: { root: path.join(__dirname, 'node_modules') }
但我收到以下錯誤,
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.resolveLoader has an unknown property 'modulesDirectories'. These properties are valid: object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
babel-loader 版本是 7.1.4 。 Webpack 升級引入了這個錯誤。 對此有何建議?
你是不是安裝了這個“babel-loader” https://www.npmjs.com/package/babel-loader
module: {
rules: [{
test: /\.jsx?$/,
include: [
path.resolve(__dirname, 'src/js'),
],
loader: "babel-loader",
options: {
presets: ["es2015"],
plugins: [
["babel-plugin-root-import", {
"rootPathSuffix": "src/js"
}],
[
"transform-runtime", {
"helpers": false,
"polyfill": false,
"regenerator": true,
"moduleName": "babel-runtime"
}
],
"transform-object-assign", "transform-function-bind"
]
},
// options for the loader
}}
只需安裝模塊:
npm install babel-loader
或者
yarn add babel-loader
我通過運行上面的命令解決了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.