所以,我在Windows上成功运行了我的第一个ReactNative项目并针对Android操作系统进行了配置。在Mac上查看项目后,按照完全相同的方式进行了配置,但是当我尝试使用react-native start
启动React软件包管理器时,出现以下错误:
child_process.js:506
throw err;
^
Error: spawnSync /Users/UserName/Desktop/Path/node_modules/react-native/local-cli/setup_env.sh EACCES
at exports._errnoException (util.js:1022:11)
at spawnSync (child_process.js:461:20)
at Object.execFileSync (child_process.js:498:13)
at Object.run (/Users/UserName/Desktop/Path/node_modules/react-native/local-cli/cliEntry.js:156:16)
at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:117:7)
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)
我知道它只试图将ulimit(打开文件限制)设置为2048,这对非根用户是允许的。我还尝试以sudo身份运行命令,赋予它root权限。
在机器上运行 ulimit -a
命令显示打开文件限制为256,我尝试将默认值2048更改为此值。我还尝试将其增加到4096,或者完全删除该命令。但似乎没有任何区别,错误仍然存在。
使用react-native init DemoProject
创建了一个新项目,打包程序似乎开始工作,所以问题不在这里?
我的package.json内容如下:
{
"name": "React Native",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"native-base": "^0.5.18",
"react": "15.4.1",
"react-addons-shallow-compare": "^15.4.1",
"react-native": "0.39.2",
"react-native-drawer": "^2.3.0",
"react-native-icons": "^0.7.1",
"react-native-loading-spinner-overlay": "^0.4.1",
"react-native-md-textinput": "^2.0.4",
"react-native-overlay": "^0.5.0",
"react-native-scrollable-tab-view": "^0.7.0",
"react-native-tab-view": "0.0.40",
"react-redux": "^4.4.6",
"react-timer-mixin": "^0.13.3",
"redux": "^3.6.0"
},
"devDependencies": {
"babel-jest": "17.0.2",
"babel-preset-react-native": "1.9.0",
"jest": "17.0.3",
"react-test-renderer": "15.4.1"
},
"jest": {
"preset": "react-native"
}
}
还有,如果这很重要,我已经全局安装了Sinopia、Browserify和Yarn。
首先,我不确定是否应该在 Mac 上再次通过 npm 添加所有本地依赖项,然后只需复制我的代码,或者这样做是可以的,但其他地方出了问题。
如果我不必重新添加依赖项就能解决这个问题,那就太好了。提前致谢。