本文根据开源内容派生,与公司无关。
派生自:https://facebook.github.io/react/docs/installation.html
为什么要配置
开发环境配置是开发和学习开发的基础,没有提供这方面的配置信息就是耍流氓。
配置步骤
前提条件
- 安装了nodejs
- 支持npm
- npm配置正确可以访问外网
运行命令
npm install -g create-react-app
create-react-app hello-world
cd hello-world
npm start
以上是官方的命令,但是发现本地运行报错:
npm WARN optional Skipping Failed optional dependency /react-scripts/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.17
npm ERR! Windows_NT 10.0.14393
npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Users\*****\AppData\Roaming\npm\node_modules\npm\bin\np
m-cli.js” “install” “–save” “–save-exact” “react” “react-dom” “react-scripts”
npm ERR! node v7.7.1
npm ERR! npm v3.8.9
npm ERR! path C:\Users****\AppData\Roaming\npm-cache\iconv-lite\0.4.13\package.tgz.603192902
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall renamenpm ERR! Error: EPERM: operation not permitted,rename ‘C:\Users\sunru\AppData\Roaming\npm-cache\iconv-lite\0.4.13\packa
ge.tgz.603192902’ -> ‘C:\Users\sunru\AppData\Roaming\npm-cache\iconv-lite\0.4.13\package.tgz’
npm ERR! { Error: EPERM: operation not permitted,rename ‘C:\Users\sunru\AppData\Roaming\npm-cache\iconv-lite\0.4.13\pa
ckage.tgz.603192902’ -> ‘C:\Users\sunru\AppData\Roaming\npm-cache\iconv-lite\0.4.13\package.tgz’
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,
npm ERR! syscall: ‘rename’,
npm ERR! path: ‘C:\Users\sunru\AppData\Roaming\npm-cache\iconv-lite\0.4.13\package.tgz.603192902’,
npm ERR! dest: ‘C:\Users\sunru\AppData\Roaming\npm-cache\iconv-lite\0.4.13\package.tgz’,
npm ERR! parent: ‘whatwg-encoding’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.npm ERR! Please include the following file with any support request:
npm ERR! E:\GitCode\JavaScript\react-apps\npm-debug.log
npm install -g react npm install -g react-dom npm install -g react-scripts
然后创建项目
create-react-app hello-world