npm start
安装 webpack后运行后,我的 react 项目出现错误。
npm install webpack
npm install webpack-dev-server
这是我的 package.json(没有上面的包)
{
"name": "myproject",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.9.3"
},
"dependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react-router": "^3.0.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
一旦我安装了 webpack 和 webpack-dev-server,我就开始收到这个错误npm start
Failed to compile.
Error in TypeError: Cannot read property '0' of undefined
- ExternalModuleFactoryPlugin.js:19
[myproject]/[webpack]/lib/ExternalModuleFactoryPlugin.js:19:40
- NormalModuleFactory.js:159
[myproject]/[react-scripts]/[webpack]/lib/NormalModuleFactory.js:159:3
- Tapable.js:75 NormalModuleFactory.applyPluginsAsyncWaterfall
[myproject]/[react-scripts]/[tapable]/lib/Tapable.js:75:69
- NormalModuleFactory.js:144 NormalModuleFactory.create
[myproject]/[react-scripts]/[webpack]/lib/NormalModuleFactory.js:144:8
- Compilation.js:356 Compilation.process [as _addModuleChain]
[myproject]/[react-scripts]/[webpack]/lib/Compilation.js:356:16
- Compilation.js:424 Compilation.process [as addEntry]
[myproject]/[react-scripts]/[webpack]/lib/Compilation.js:424:7
- SingleEntryPlugin.js:24 Compiler.<anonymous>
[myproject]/[webpack]/lib/SingleEntryPlugin.js:24:16
- Tapable.js:107 Compiler.applyPluginsParallel
[myproject]/[react-scripts]/[tapable]/lib/Tapable.js:107:14
- Compiler.js:394 Compiler.compile
[myproject]/[react-scripts]/[webpack]/lib/Compiler.js:394:7
- Compiler.js:203 Compiler.runAsChild
[myproject]/[react-scripts]/[webpack]/lib/Compiler.js:203:7
- compiler.js:70
[myproject]/[html-webpack-plugin]/lib/compiler.js:70:19
- compiler.js:69 Object.compileTemplate
[myproject]/[html-webpack-plugin]/lib/compiler.js:69:10
这是我的 npm 版本。
$ npm -v
4.5.0
这与我的代码有关还是与 npm/react-scripts 有问题?