簡體   English   中英

Webpack React錯誤

[英]Webpack React Error

我重新啟動了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是最新版本!!!

使用babel-loader而不是babel-core

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM