我重启了我的MAC,之后我得到了错误......
Babel已切换到Babel-core,因此我将其卸载并将webpack中的加载程序更改为babel-core。
现在当我运行npm run bundle
时,我收到了以下错误:
/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/loadLoader.js:35
throw new Error("Module '" + loader.path + "' is not a loader (must have normal or pitch function)");
^
Error: Module '/Users/imac/Desktop/fakeeh/node_modules/babel-core/index.js' is not a loader (must have normal or pitch function)
at loadLoader (/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/loadLoader.js:35:10)
at iteratePitchingLoaders (/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
at runLoaders (/usr/local/lib/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
at NormalModule.doBuild (/usr/local/lib/node_modules/webpack/lib/NormalModule.js:181:3)
at NormalModule.build (/usr/local/lib/node_modules/webpack/lib/NormalModule.js:274:15)
at Compilation.buildModule (/usr/local/lib/node_modules/webpack/lib/Compilation.js:149:10)
at moduleFactory.create (/usr/local/lib/node_modules/webpack/lib/Compilation.js:447:10)
at factory (/usr/local/lib/node_modules/webpack/lib/NormalModuleFactory.js:241:5)
at applyPluginsAsyncWaterfall (/usr/local/lib/node_modules/webpack/lib/NormalModuleFactory.js:94:13)
at /usr/local/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:268:11
at NormalModuleFactory.params.normalModuleFactory.plugin (/usr/local/lib/node_modules/webpack/lib/CompatibilityPlugin.js:52:5)
at NormalModuleFactory.applyPluginsAsyncWaterfall (/usr/local/lib/node_modules/webpack/node_modules/tapable/lib/Tapable.js:272:13)
at resolver (/usr/local/lib/node_modules/webpack/lib/NormalModuleFactory.js:69:10)
at process.nextTick (/usr/local/lib/node_modules/webpack/lib/NormalModuleFactory.js:194:7)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
npm ERR! Darwin 16.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "bundle"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! fakeeh@0.1.0 bundle: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fakeeh@0.1.0 bundle script 'webpack'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the fakeeh package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs fakeeh
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls fakeeh
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/imac/Desktop/fakeeh/npm-debug.log
这里也是webpack配置:
const path = require('path');
module.exports = {
// the entry file for the bundle
entry: path.join(__dirname, '/client/src/app.jsx'),
// the bundle file we will get in the result
output: {
path: path.join(__dirname, '/client/dist/js'),
filename: 'app.js',
},
module: {
// apply loaders to files that meet given conditions
loaders: [{
test: /\.jsx?$/,
include: path.join(__dirname, '/client/src'),
loader: 'babel-core',
}],
},
// start Webpack in a watch mode, so Webpack will rebuild the bundle on changes
watch: true
};
毕竟,在Chrome控制台中,同样的错误...... Module build failed: Error: The node API for babel has been moved to babel-core.
您认为问题是什么?
注意:NPM和Node是最新版本!!!
答案 0 :(得分:2)
使用babel-loader
代替babel-core