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. TP5.1教程第十章三小节的用户注册章节,不能显示bootstrap的菜单下拉,也不能script验2. 怎样使留言的数据与登录的用户名,密码保持一致(在数据库上是一行的)。3. html - css气泡,实现“倒三角(不知道算不算三角了)”可透明的。4. angular.js - vue or angular.2 or react5. win10 Apache24+PHP8.0,Apache不能正常加载php.ini。6. 前端 - 访问Apache文档目录下的HTML文件变成了下载该页面?7. 如何通过Java编码生成Jmeter仪表板报告(不是Windows或Shell命令)8. css - sudo gem install jekyII 出现错误9. PHP中的$this代表当前的类还是方法?10. javascript - 关于clone vue2.0项目,运行不了的问题
