javascript - webpack打包出現(xiàn)react-dom相關(guān)錯(cuò)誤
問題描述
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);控制臺(tái)錯(cuò)誤
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方法中是什么意思?
相關(guān)文章:
1. objective-c - ios百度地圖定位問題2. javascript - 求助這種功能有什么好點(diǎn)的插件?3. 微信開放平臺(tái) - Android調(diào)用微信分享不顯示4. javascript - 關(guān)于這組數(shù)據(jù)如何實(shí)現(xiàn) 按字母列表分類展示 不改動(dòng)數(shù)據(jù)結(jié)構(gòu)5. javascript - 寫移動(dòng)端的頁面的時(shí)候,有不一快空白,是怎么回事?6. html5 - rudy編譯sass的時(shí)候有中文報(bào)錯(cuò)7. javascript - 關(guān)于定時(shí)器 與 防止連續(xù)點(diǎn)擊 問題8. javascript - ie11以下單擊打開不了file,雙擊可以。求解?9. javascript - 在IE中(9+)平時(shí)的樣式不生效,只有用開發(fā)者工具選中這個(gè)元素才生效,是什么原因?10. Python做掃描,發(fā)包速度實(shí)在是太慢了,有優(yōu)化的方案嗎?
