Windows 7,npm install -g react-native-cli给出“无法读取属性'null的null路径'". [英] Windows 7, npm install -g react-native-cli gives "Cannot read property 'path' of null"

查看:170
本文介绍了Windows 7,npm install -g react-native-cli给出“无法读取属性'null的null路径'".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过遵循此处的官方文档来开始起步,以响应本机教程

I am Beginning the getting started react native tutorial by following the official docs from here https://facebook.github.io/react-native/docs/getting-started.html

  1. 顺利安装choco,nodejs和python
  2. 在执行npm install -g react-native-cli时,我得到无法读取null的属性'path'"(下面是完整错误)

npm install -g react-native-cli

C:\Windows\system32>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:\Windows\system32\npm-debug.log

C:\Windows\system32>

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 Files\nodejs\node_modules\npm\lib\install.js:511:29)
30 verbose stack     at Array.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8)
30 verbose stack     at LOOP (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:15:14)
30 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:18:7
30 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\install.js:337:5
30 verbose stack     at Array.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8)
30 verbose stack     at LOOP (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:15:14)
30 verbose stack     at chain (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:20:5)
30 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\install.js:294:5
30 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:16:22
31 verbose cwd C:\Windows\system32
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 ]

这是我尝试过的,

  1. 检查了文件夹"C:\ Program Files \ nodejs \ node_modules"的权限,发现其为只读
  2. 已将所有权转让给我和管理员用户,并对其拥有完全控制权,然后通过attrib -r -s C:\ Program Files \ nodejs \ node_modules/S/D删除了只读权限
  3. 当我检查文件夹的权限时,它仍然是只读的,但其中的所有文件都不处于只读的控制下
  4. 再次执行"npm install react-native-cli"命令,导致相同的错误

解决方案

  1. 如果您以前使用过Sinopia并创建了.npmrc文件,请重命名或删除配置文件
  2. 使用npm install -g react-native-cli成功安装lib

理由

  1. Sinopia配置文件将使npm首先在本地计算机上查找软件包,如果找不到,则在npmjs.com上获取软件包
  2. 我之前安装并使用了Sinopia,后来又卸载了它,但看起来配置文件并未被删除 3.因此,配置文件使npm在本地计算机上查找软件包,而本地服务器根本没有运行,表明软件包不可用!
  1. Sinopia config file will make npm to look for packages in the local machine first and if it is not found, then goes to fetch the package at npmjs.com
  2. I had earlier installed and used Sinopia and uninstalled it later, but looks like the config file was not removed 3.So the config file made npm look for packages in the local machine, whereas the local server was not at all running in the first place to say the package was not available !

推荐答案

我认为您正在使用代理,是" http ://localhost:4873/您代理(或设置自定义注册表)? 如果是这样,则最好检查一下网络,并确保可以使用npm正常安装其他模块.

I think you're using a proxy, is "http://localhost:4873/" you proxy(or you set a custom registry)? If it is, you had better check your network, and make sure your can use npm to install others module normally.

错误:连接ECONNREFUSED 127.0.0.1:4873"表明它无法连接到127.0.0.1:4873

"Error: connect ECONNREFUSED 127.0.0.1:4873" shows that it can not connect to 127.0.0.1:4873

这篇关于Windows 7,npm install -g react-native-cli给出“无法读取属性'null的null路径'".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆