javascript - webpack打包出现react-dom相关错误
问题描述
login.js代码import React from ’react’;import ReactDOM from ’react-dom’;function tick() { const element = ( <p> <h1>Hello, world!</h1> <h2>It is {new Date().toLocaleTimeString()}.</h2> </p> ); ReactDOM.render( element, document.getElementById(’root’) );}webpack.config.js代码
const webpack = require(’webpack’);const path=require(’path’);module.exports=(env)=>{ return {entry:{ main:’./login.js’, vendor1:’React’, vendor2:’ReactDOM’},output:{ filename:’[name].bundle.js’, path:path.resolve(__dirname,’dist’)}, module: { rules: [ {test: /.(js|jsx)$/,loader: ’babel-loader’ } ] },plugins:[ new webpack.optimize.CommonsChunkPlugin({name:’manifest’ }),/* new webpack.optimize.CommonsChunkPlugin({name:’vendor1’,minChunks:(module)=>{ return module.context&&module.context.indexOf(’node_modules’)!==-1;} }), new webpack.optimize.CommonsChunkPlugin({name:’vendor2’,minChunks:(module)=>{ return module.context&&module.context.indexOf(’node_modules’)!==-1;} })*/] }}setInterval(tick, 1000);控制台错误
WARNING in D:/node/likeread/~/React/lib/ReactPropTypesSecret.jsThere are multiple modules with names that only differ in casing.This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.Use equal casing. Compare these module identifiers:* D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesReactlibReactPropTypesSecret.js Used by 1 module(s), i. e. D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesReactlibcheckReactTypeSpec.js* D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesreactlibReactPropTypesSecret.js Used by 1 module(s), i. e. D:nodelikereadnode_modulesbabel-loaderlibindex.js!D:nodelikereadnode_modulesreactlibcheckReactTypeSpec.jsERROR in Entry module not found: Error: Can’t resolve ’ReactDOM’ in ’D:nodelikereadpublicjavascripts’
问题解答
回答1:你把ReactDOM.render()写在tick方法中是什么意思?
相关文章:
1. 编辑成功不显示弹窗2. 哭辽 求大佬解答 控制器的join方法怎么转模型方法3. Navicat for mysql 中以json格式储存的数据存在大量反斜杠,如何去除?4. mysql - 数据库表中,两个表互为外键参考如何解决5. mysql储存json错误6. mysql - 怎么生成这个sql表?7. mysql - 表名称前缀到底有啥用?8. sql语句 - 如何在mysql中批量添加用户?9. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE语法实现存在即更新应该使用哪个标签?10. 怎么php怎么通过数组显示sql查询结果呢,查询结果有多条,如图。
