我正在开始启动启动react react本地教程,从这里遵循官方文档https://facebook.github.io/react-native/docs/docs/getting-started.html
- 完成安装Choco,Nodejs和Python没有任何麻烦
- 在执行NPM安装-g react-native-cli时,我得到"无法读取null的属性'路径"(下面的完整错误)
npm install -g react-native-cli
C:Windowssystem32>npm install -g react-native-cli
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "react-native-cli"
npm ERR! node v7.6.0
npm ERR! npm v4.1.2
npm ERR! Cannot read property 'path' of null
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:Windowssystem32npm-debug.log
C:Windowssystem32>
npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'react-native-cli' ]
2 info using npm@4.1.2
3 info using node@v7.6.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData react-native-cli
8 silly fetchNamedPackageData react-native-cli
9 silly mapToRegistry name react-native-cli
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry http://localhost:4873/
12 silly mapToRegistry data Result {
12 silly mapToRegistry raw: 'react-native-cli',
12 silly mapToRegistry scope: null,
12 silly mapToRegistry escapedName: 'react-native-cli',
12 silly mapToRegistry name: 'react-native-cli',
12 silly mapToRegistry rawSpec: '',
12 silly mapToRegistry spec: 'latest',
12 silly mapToRegistry type: 'tag' }
13 silly mapToRegistry uri http://localhost:4873/react-native-cli
14 verbose request uri http://localhost:4873/react-native-cli
15 verbose request no auth needed
16 info attempt registry request try #1 at 4:37:49 PM
17 verbose request using bearer token for auth
18 verbose request id 91c9343245cf6325
19 http request GET http://localhost:4873/react-native-cli
20 info retry will retry, error on last attempt: Error: connect ECONNREFUSED 127.0.0.1:4873
21 info attempt registry request try #2 at 4:38:00 PM
22 verbose request using bearer token for auth
23 http request GET http://localhost:4873/react-native-cli
24 info retry will retry, error on last attempt: Error: connect ECONNREFUSED 127.0.0.1:4873
25 info attempt registry request try #3 at 4:39:01 PM
26 verbose request using bearer token for auth
27 http request GET http://localhost:4873/react-native-cli
28 silly fetchPackageMetaData Error: connect ECONNREFUSED 127.0.0.1:4873
28 silly fetchPackageMetaData at Object.exports._errnoException (util.js:1028:11)
28 silly fetchPackageMetaData at exports._exceptionWithHostPort (util.js:1051:20)
28 silly fetchPackageMetaData at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
28 silly fetchPackageMetaData error for react-native-cli { Error: connect ECONNREFUSED 127.0.0.1:4873
28 silly fetchPackageMetaData at Object.exports._errnoException (util.js:1028:11)
28 silly fetchPackageMetaData at exports._exceptionWithHostPort (util.js:1051:20)
28 silly fetchPackageMetaData at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
28 silly fetchPackageMetaData code: 'ECONNREFUSED',
28 silly fetchPackageMetaData errno: 'ECONNREFUSED',
28 silly fetchPackageMetaData syscall: 'connect',
28 silly fetchPackageMetaData address: '127.0.0.1',
28 silly fetchPackageMetaData port: 4873 }
29 silly rollbackFailedOptional Starting
30 verbose stack TypeError: Cannot read property 'path' of null
30 verbose stack at Installer.rollbackFailedOptional (C:Program Filesnodejsnode_modulesnpmlibinstall.js:511:29)
30 verbose stack at Array.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesslidelibbind-actor.js:15:8)
30 verbose stack at LOOP (C:Program Filesnodejsnode_modulesnpmnode_modulesslidelibchain.js:15:14)
30 verbose stack at C:Program Filesnodejsnode_modulesnpmnode_modulesslidelibchain.js:18:7
30 verbose stack at C:Program Filesnodejsnode_modulesnpmlibinstall.js:337:5
30 verbose stack at Array.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesslidelibbind-actor.js:15:8)
30 verbose stack at LOOP (C:Program Filesnodejsnode_modulesnpmnode_modulesslidelibchain.js:15:14)
30 verbose stack at chain (C:Program Filesnodejsnode_modulesnpmnode_modulesslidelibchain.js:20:5)
30 verbose stack at C:Program Filesnodejsnode_modulesnpmlibinstall.js:294:5
30 verbose stack at C:Program Filesnodejsnode_modulesnpmnode_modulesslidelibchain.js:16:22
31 verbose cwd C:Windowssystem32
32 error Windows_NT 6.1.7601
33 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "react-native-cli"
34 error node v7.6.0
35 error npm v4.1.2
36 error Cannot read property 'path' of null
37 error If you need help, you may report this error at:
37 error <https://github.com/npm/npm/issues>
38 verbose exit [ 1, true ]
这是我尝试的,
- 检查了文件夹" C: Program Files nodejs node_modules"的许可,并发现其ReadOnly
- 已将所有权转移并分配给我自己和管理员用户,然后仅通过attrib -r -s c: program文件 nodejs node_modules/s/s/d 除读取。
- 当我检查文件夹的许可时,它仍然仅读取,但是内部的所有文件都不在读取 的控制下
- 再次执行" NPM安装react-native-cli"命令,该命令导致相同的错误
解决方案
- 如果您较早使用过Sinopia并创建了.NPMRC文件,则重命名或删除配置文件
- 使用npm install -G react-native-cli成功安装lib
推理
- Sinopia配置文件将使NPM首先在本地计算机中查找软件包,如果找不到,则可以在NPMJs.com上获取软件包
- 我早些时候已经安装并使用了新加坡并卸载了它,但看起来配置文件没有被删除3.因此,配置文件使NPM在本地计算机中查找包装,而本地服务器根本没有运行,说该软件包不可用!
我认为您正在使用代理,是" http://localhost:4873/"您代理(或者您设置了自定义注册表)?如果是这样,您最好检查您的网络,并确保您可以使用NPM正常安装其他模块。
"错误:连接Econnrefuse 127.0.0.1:4873"表明它无法连接到127.0.0.1:4873
我认为您的NPM路径未在环境变量中设置。请设置您的NPM路径或从安装NPM的位置运行此命令。在Windows中设置环境变量1.转到我的计算机中的属性。2.转到高级系统设置。3.然后转到环境变量。4.然后在路径变量中添加NPM路径。例如C: Users Myuser AppData roaming npm;