javascript - React.js 错误 : Invariant Violation: Minified React error #37

标签 javascript git reactjs webpack react-redux

我已经尝试在互联网上查找,但找不到解决此错误的方法。

基本上,当我通过 npm start 在我的本地主机上运行我的应用程序时,它运行没有问题。

但是,当我切换到 git branch gh-pages 以在 gh-pages 中托管时,我在 console.log 中看到以下错误

Uncaught Invariant Violation: Minified React error #37

_registerComponent(...): Target container is not a DOM element是错误 #37 的意思。

Link to Git App Repository gh-pages branch

这是我当前的设置:

webpack.config.js

var path = require('path');
var webpack = require('webpack');
var ghpages = require('gh-pages');
var WriteFilePlugin = require('write-file-webpack-plugin');
module.exports = {
  devtool: 'source-map',
  entry: [
    './src/index.js'
  ],
  output: {
    publicPath: '/',
    filename: 'bundle.js',
    sourceMapFilename: "./bundle.js.map",
    path: path.join(__dirname, './static')
  },
  module: {
    loaders: [{
      exclude: /node_modules/,
      loader: 'babel',
      query: {
        presets: ['react', 'es2015', 'stage-1']
      }
    },{
      test: /\.s?css$/,
      loaders: ['style','css','sass'],
      include: path.join(__dirname, 'src')
    }]
  },
  resolve: {
    extensions: ['', '.js', '.jsx'],
    alias: {
    'jquery': path.join(__dirname, 'node_modules/jquery/dist/jquery'),
    }
  },
  devServer: {
    historyApiFallback: true,
    contentBase: './',
    outputPath: path.join(__dirname, './dist')
  }
};

package.json

{
  "name": "recipe-box",
  "version": "1.0.0",
  "description": "Portfolio",
  "main": "index.js",
  "repository": "",
  "scripts": {
    "start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js",
    "test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js --recursive ./test",
    "test:watch": "npm run test -- --watch",
    "postinstall": "webpack -p"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.2.1",
    "babel-loader": "^6.2.0",
    "babel-preset-es2015": "^6.1.18",
    "babel-preset-react": "^6.1.18",
    "chai": "^3.5.0",
    "chai-jquery": "^2.0.0",
    "file-loader": "^0.9.0",
    "gh-pages": "^0.11.0",
    "image-webpack-loader": "^2.0.0",
    "jquery": "^3.1.0",
    "jsdom": "^9.5.0",
    "mocha": "^3.0.2",
    "node-sass": "^3.8.0",
    "react-addons-test-utils": "^15.3.1",
    "webpack": "^1.13.2",
    "webpack-dev-server": "^1.14.0",
    "write-file-webpack-plugin": "^3.3.0"
  },
  "dependencies": {
    "babel-preset-stage-1": "^6.1.18",
    "css-loader": "^0.25.0",
    "express": "^4.14.0",
    "jquery": "^2.2.4",
    "lodash": "^4.16.1",
    "materialize-css": "^0.97.7",
    "node-sass": "^3.8.0",
    "react": "^15.3.1",
    "react-bootstrap": "^0.30.3",
    "react-dom": "^15.3.1 ",
    "react-materialize": "^0.16.4",
    "react-redux": "^4.0.0",
    "react-router": "^2.0.1",
    "react-tap-event-plugin": "^1.0.0",
    "redux": "^3.0.4",
    "redux-logger": "^2.6.1",
    "sass-loader": "^4.0.0",
    "shortid": "^2.2.6",
    "style-loader": "^0.13.1"
  }
}

最佳答案

回答了我自己的问题

看起来我必须将 bundle.jsdist 文件夹移到我的 index.html 所在的同一目录。

关于javascript - React.js 错误 : Invariant Violation: Minified React error #37,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40073828/

相关文章:

javascript - Mpeg Dash html5 播放器或直播视频

git - 配置 IntelliJ IDEA 以始终忽略由 Maven Release Plugin 在 target/checkout 创建的 Git Roots

通过分支重组 git repo

javascript - 如何在 React.js 中显示下拉菜单和隐藏其他菜单

javascript - 在 React 应用程序中使用 Google OAuth2 刷新/使用刷新 token 后保持用户登录

javascript - 如何在ul中通过jquery添加列表项?

javascript - Typescript 和 ExpressJs 提供的脚本未运行

c# - 使用 Git 和 Visual Studio 检查项目

reactjs - 弯曲方向 : "row" not working react-native

javascript - ng-repeat 过滤器不适用于引号