我正在努力让Udemy Modern与redux做出反应。我克隆了存储库,一切都没有得到与udemy教授相同的结果。相反,我得到以下内容。我更新到节点3.10.8并运行:
npm install babel-runtime --save-dev
当我运行npm install时效果很好但是当我运行npm start时出现此错误:
http://localhost:8080/webpack-dev-server/
webpack result is served from /
content is served from ./
404s will fallback to /index.html
Hash: d437a155a1da4cdfeeeb
Version: webpack 1.13.3
Time: 79ms
Asset Size Chunks Chunk Names
bundle.js 1.51 kB 0 [emitted] main
chunk {0} bundle.js (main) 28 bytes [rendered]
[0] multi main 28 bytes {0} [built] [1 error]
ERROR in ./src/index.js
Module build failed: Error: Cannot find module '../modules/web.dom.iterable' (While processing preset: "C:\\Users\\Ryan\
\Documents\\simplestarter\\ReduxSimpleStarter\\node_modules\\babel-preset- react\\lib\\index.js")
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous>(C:\Users\Ryan\Documents\simplestarter\ReduxSimpleStarter\node_modules\babel-preset-react\node
_modules\babel-plugin-transform-react-jsx\node_modules\babel-runtime\node_modules\core-js\library\fn\get-iterator.js:1:6
3)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
@ multi main
package.json内容:
{
"name": "redux-simple-starter",
"version": "1.0.0",
"description": "Simple starter package for Redux with React and Babel support",
"main": "index.js",
"repository": "git@github.com:StephenGrider/ReduxSimpleStarter.git",
"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"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.18.0",
"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",
"jquery": "^2.2.1",
"jsdom": "^8.1.0",
"mocha": "^2.4.5",
"react-addons-test-utils": "^0.14.7",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"babel-preset-stage-1": "^6.1.18",
"lodash": "^3.10.1",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "^4.0.0",
"react-router": "^2.0.1",
"redux": "^3.0.4"
}
}
发生了什么事?我需要下载一种新形式的babel吗?
答案 0 :(得分:1)
尝试重新安装本地模块。您可以使用以下一系列命令:
rm -rf node_modules ; npm install
这应该重新安装你在package.json中配置的所有内容。祝你好运!
答案 1 :(得分:1)
我收到同样的错误,这对我有用! 在第1节第14分钟7:17讲座中你可以看到他在第13行的结束div之后有一个分号:
分号很可能是一个错字,因为他在7:28分钟没有说什么就删掉它。至少对我来说,由于语法错误,webpack无法编译。 一旦我删除了分号,一切正常!