'react-native init'错误:npm ERR!命令失败:混帐取-a起源
问题描述:
发生了错误,而我试图通过初始化一个反应本地项目:react-native init awesomeProject
:'react-native init'错误:npm ERR!命令失败:混帐取-a起源
Installing react-native package from npm...
`npm install --save react-native` failed
然后我手动运行该命令故宫,错误看起来像发生在这里:
npm verb afterAdd /Users/mc-zone/.npm/joi/6.9.1/package/package.json not in flight; writing
npm verb afterAdd /Users/mc-zone/.npm/joi/6.9.1/package/package.json written
npm ERR! git fetch -a origin (git://github.com/facebook/react.git) fatal: Unable to create temporary file '/Users/mc-zone/.npm/_git-remotes/git-github-com-facebook-react-git-baa2986b/./objects/pack/tmp_pack_XXXXXX': Permission denied
npm ERR! git fetch -a origin (git://github.com/facebook/react.git) fatal: index-pack failed
npm verb about to build /Users/mc-zone/_dev/rn/node_modules/react-native
npm verb unlock done using /Users/mc-zone/.npm/_locks/react-native-ce52a7d7697a2d98.lock for /Users/mc-zone/_dev/rn/node_modules/react-native
npm verb stack Error: Command failed: git fetch -a origin
npm verb stack fatal: Unable to create temporary file '/Users/mc-zone/.npm/_git-remotes/git-github-com-facebook-react-git-baa2986b/./objects/pack/tmp_pack_XXXXXX': Permission denied
npm verb stack fatal: index-pack failed
npm verb stack
npm verb stack at ChildProcess.exithandler (child_process.js:203:12)
npm verb stack at emitTwo (events.js:87:13)
npm verb stack at ChildProcess.emit (events.js:172:7)
npm verb stack at maybeClose (internal/child_process.js:818:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
npm verb cwd /Users/mc-zone/_dev/rn
npm ERR! Darwin 14.3.0
npm ERR! argv "/Users/mc-zone/.nvm/versions/node/v4.2.1/bin/node" "/Users/mc-zone/.nvm/versions/node/v4.2.1/bin/npm" "install" "react-native" "--save"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! code 128
npm ERR! Command failed: git fetch -a origin
npm ERR! fatal: Unable to create temporary file '/Users/mc-zone/.npm/_git-remotes/git-github-com-facebook-react-git-baa2986b/./objects/pack/tmp_pack_XXXXXX': Permission denied
npm ERR! fatal: index-pack failed
npm ERR!
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm verb exit [ 1, true ]
似乎是一个权限的问题,我也用sudo chown -R $USER ~/.npm
仍然没有工作。
这npm install
由react-native-cli
excuted所以我不能添加sudo
命令npm
(sudo react-native init
仍然无法正常工作)
我怎样才能解决这个问题?
========
其他资料:
系统:Mac OS X 10.10.3
npm
由nvm
安装安装node
时。
nvm
由brew
安装。
$ npm -v
2.14.7
$ node -v
v4.2.1
而且有我的文件夹的权限(想在_dev
来初始化应用程序):
drwxrwxrwx 521 mc-zone staff 17714 10 17 19:20 .npm
-rw------- 1 mc-zone staff 56 10 17 17:01 .npmrc
drwxrwxrwx 5 mc-zone staff 170 10 17 16:57 .nvm
drwxrwxrwx 4 mc-zone staff 136 10 16 23:15 _dev
答
我有同样的问题,并通过给予或接受的权限,可以在安装文件夹中解决它:
➜ ~ sudo chmod 774 ProjectFolder/*
➜ ~ sudo chown Username ProjectFolder/*
➜ ~ sudo chmod 774 .babel.json
➜ ~ sudo chown Username .babel.json
答
以下是创建新项目CRNA并从展会运行的一些步骤。
step1:如果您已经安装了crna,请跳过此步骤。
NPM安装-g创建反应的原生应用程序内第二步:创建反应的原生应用程序内AwesomeProject
第三步:CD AwesomeProject
第四步:NPM启动或启动纱
享受