React Native init 在新项目中不起作用 [英] React native init is not working in new fresh project
问题描述
我正在尝试使用 react-native 0.59.8 创建一个新项目,但失败了.
I'm trying to create a fresh project with react-native 0.59.8 but is failing.
我尝试了不同版本的 react-native,所以我认为问题出在我使用的纱线、节点或 npm 版本中.
I have tried different versions of react-native so I think the problem is in yarn, node or npm versions that i'm using.
{ Error: Command failed: yarn add react-native --exact
at checkExecSyncError (child_process.js:616:11)
at execSync (child_process.js:653:13)
at run (/Users/francesco/.nvm/versions/node/v10.15.3/lib/node_modules/react-native-cli/index.js:294:5)
at createProject (/Users/francesco/.nvm/versions/node/v10.15.3/lib/node_modules/react-native-cli/index.js:249:3)
at init (/Users/francesco/.nvm/versions/node/v10.15.3/lib/node_modules/react-native-cli/index.js:200:5)
at Object.<anonymous> (/Users/francesco/.nvm/versions/node/v10.15.3/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12) }
我的堆栈是:
- 节点:10.15.3
- npm:6.4.1
- 纱线:1.16.0
- react-native-cli: 2.0.1
推荐答案
先尝试清除 yarn 缓存:yarn cache clean
.然后运行react-native init 项目名称
您使用的是哪个操作系统?
Try clearing yarn cache first : yarn cache clean
. Then run
react-native init ProjectName
Which OS you are using ?
更新:解决方案:这是因为 react-native init 正在另一个文件系统上运行(在这种情况下是谷歌驱动器).将 react-native init projectname
的位置更改为操作系统正在使用的默认文件系统.
Update:
Solution: It was because react-native init was running on another file system(google drive in this case). Changing the location of react-native init projectname
to default file system that OS is using worked.
这篇关于React Native init 在新项目中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!