npm install返回“TypeError:无法将undefined或null转换为object”

时间:2016-12-13 19:03:13

标签: node.js npm npm-install nvm

我正在尝试使用npm install -g eslint全局安装eslint。这是使用nvm安装的节点@ 7.2.1 / npm @ 3.10.10的最新版本。我得到的错误是:

堆栈跟踪:

0 info it worked if it ends with ok
1 verbose cli [ '/Users/fitvalet/.nvm/versions/node/v7.2.1/bin/node',
1 verbose cli   '/Users/fitvalet/.nvm/versions/node/v7.2.1/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'eslint' ]
2 info using npm@3.10.10
3 info using node@v7.2.1
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData eslint
8 silly fetchNamedPackageData eslint
9 silly mapToRegistry name eslint
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry http://skimdb.npmjs.com/registry
12 silly mapToRegistry data Result {
12 silly mapToRegistry   raw: 'eslint',
12 silly mapToRegistry   scope: null,
12 silly mapToRegistry   escapedName: 'eslint',
12 silly mapToRegistry   name: 'eslint',
12 silly mapToRegistry   rawSpec: '',
12 silly mapToRegistry   spec: 'latest',
12 silly mapToRegistry   type: 'tag' }
13 silly mapToRegistry uri http://skimdb.npmjs.com/registry/eslint
14 verbose request uri http://skimdb.npmjs.com/registry/eslint
15 verbose request no auth needed
16 info attempt registry request try #1 at 1:59:17 PM
17 verbose request id 066241c6e4150db4
18 http request GET http://skimdb.npmjs.com/registry/eslint
19 http 200 http://skimdb.npmjs.com/registry/eslint
20 verbose headers { 'cache-control': 'must-revalidate',
20 verbose headers   connection: 'close',
20 verbose headers   'content-type': 'application/json',
20 verbose headers   date: 'Tue, 13 Dec 2016 18:59:17 GMT',
20 verbose headers   server: 'CouchDB/2.0.0 (Erlang OTP/R16B03)',
20 verbose headers   'transfer-encoding': 'chunked',
20 verbose headers   'content-encoding': 'gzip',
20 verbose headers   'strict-transport-security': 'max-age=2592000000; includeSubDomains; preload;' }
21 silly get cb [ 200,
21 silly get   { 'cache-control': 'must-revalidate',
21 silly get     connection: 'close',
21 silly get     'content-type': 'application/json',
21 silly get     date: 'Tue, 13 Dec 2016 18:59:17 GMT',
21 silly get     server: 'CouchDB/2.0.0 (Erlang OTP/R16B03)',
21 silly get     'transfer-encoding': 'chunked',
21 silly get     'content-encoding': 'gzip',
21 silly get     'strict-transport-security': 'max-age=2592000000; includeSubDomains; preload;' } ]
22 verbose get saving undefined to /Users/fitvalet/.npm/skimdb.npmjs.com/registry/eslint/.cache.json
23 verbose correctMkdir /Users/fitvalet/.npm correctMkdir not in flight; initializing
24 verbose makeDirectory /Users/fitvalet/.npm creation not in flight; initializing
25 silly makeDirectory /Users/fitvalet/.npm uid: 501 gid: 20
26 verbose stack TypeError: Cannot convert undefined or null to object
26 verbose stack     at Function.keys (<anonymous>)
26 verbose stack     at pickVersionFromRegistryDocument (/Users/fitvalet/.nvm/versions/node/v7.2.1/lib/node_modules/npm/lib/fetch-package-metadata.js:125:29)
26 verbose stack     at /Users/fitvalet/.nvm/versions/node/v7.2.1/lib/node_modules/npm/node_modules/iferr/index.js:13:50
26 verbose stack     at /Users/fitvalet/.nvm/versions/node/v7.2.1/lib/node_modules/npm/lib/utils/pulse-till-done.js:20:8
26 verbose stack     at saved (/Users/fitvalet/.nvm/versions/node/v7.2.1/lib/node_modules/npm/lib/cache/caching-client.js:174:7)
26 verbose stack     at /Users/fitvalet/.nvm/versions/node/v7.2.1/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:241:18
26 verbose stack     at FSReqWrap.oncomplete (fs.js:111:15)
27 verbose cwd /Users/fitvalet
28 error Darwin 16.1.0
29 error argv "/Users/fitvalet/.nvm/versions/node/v7.2.1/bin/node" "/Users/fitvalet/.nvm/versions/node/v7.2.1/bin/npm" "install" "-g" "eslint"
30 error node v7.2.1
31 error npm  v3.10.10
32 error Cannot convert undefined or null to object
33 error If you need help, you may report this error at:
33 error     <https://github.com/npm/npm/issues>
34 verbose exit [ 1, true ]

1 个答案:

答案 0 :(得分:1)

问题是我有一个旧的.npmrc指向使用skimdb.npmjs.org的npm注册表。我删除了文件,我的模块现在安装正常。

我可以通过输入npm config list registry检查注册表,现在指出我认为是默认值:https://registry.npmjs.org/