javascript - 找不到模块 'babel-core' 中的错误。使用 react.js、webpack 和 express 服务器

标签 javascript express reactjs webpack babeljs

每当我在终端中运行 webpack 时,我都会得到:

Hash: efea76b1048c3a97b963
Version: webpack 1.12.13
Time: 33ms
    + 1 hidden modules

ERROR in Cannot find module 'babel-core'

这是我的webpack.config.js文件

module.exports = {
  entry: './app-client.js',
  output: {
    filename: 'public/bundle.js'
  },
  module: {
    loaders: [
      {
        exclude: /(node_modules|app-server.js)/,
        loader: 'babel'
      }
    ]
  }
}

package.json

{
  "name": "react",
  "version": "1.0.0",
  "description": "React polling app",
  "main": "app-client.js",
  "dependencies": {
    "babel-loader": "^6.2.2",
    "bootstrap": "^3.3.6",
    "express": "^4.13.4",
    "react": "^0.14.7"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

最佳答案

你应该在安装 npm 时安装 babel-loader 和 babel-core 作为开发依赖。

npm install babel-core babel-loader --save-dev

关于javascript - 找不到模块 'babel-core' 中的错误。使用 react.js、webpack 和 express 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35215461/

相关文章:

javascript - 将数据从 Jade View 传递到 Controller

ios - 解压速度太慢

javascript - vue.js : error unknown action type?

node.js - Node Express/Sequelize App - PostgreSQL 干净退出

node.js - Mongoose 预保存钩子(Hook)触发,但不保留数据

symfony - 如何将运行时变量传递到react/webpack模块中

javascript - TypeError : 'caller' , 'callee' 和 'arguments' 属性可能无法在严格模式函数或调用的参数对象上访问

javascript - 使用按钮 onclick 计算正确答案

javascript - Kendo ui Grid 内联编辑,带有 editorTemplate 的字段

javascript - 从 Google App Engine 中的 .js 文件调用 JavaScript 函数