Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用私有的npm仓库,当我使用nrm use xxx时,报错 customRegistries.hasOwnProperty is not a function, v1.2.1 #74

Closed
Lawrence51 opened this issue Dec 10, 2020 · 6 comments

Comments

@Lawrence51
Copy link

No description provided.

@whatthehan
Copy link

mark

@bramblex
Copy link

https://github.com/npm/ini/blob/master/ini.js#L86

不关 nrm 的事情,是依赖 ini.js 作的妖……

@daifuying
Copy link

https://github.com/npm/ini/blob/master/ini.js#L86

不关 nrm 的事情,是依赖 ini.js 作的妖……

怎么解决呀亲?

@bramblex
Copy link

https://github.com/npm/ini/blob/master/ini.js#L86
不关 nrm 的事情,是依赖 ini.js 作的妖……

怎么解决呀亲?

可以先手动修改代码简单粗暴解决一下。
node_modules/nrm/cli.js 415行替换成下面代码即可。

    return fs.existsSync(NRMRC) ? JSON.parse(JSON.stringify(ini.parse(fs.readFileSync(NRMRC, 'utf-8')))) : {};

@marklbp
Copy link

marklbp commented Jan 7, 2021

这个问题其实多少和nrm源码严谨度有关系,判断一个属性是否为对象的自有属性,不应该直接在对象上调用一般默认继承的hasOwnProperty方法。

错误示范:

var allRegistries = getAllRegistry();
if (allRegistries.hasOwnProperty(name)) {
     // ...
}

正确示范:

var allRegistries = getAllRegistry();
if (Object.prototype.hasOwnProperty.call(allRegistries, name)) {
     // ...
}

@EmilyMew
Copy link
Collaborator

@marklbp 感谢,已经修改了这个问题

@i5ting i5ting closed this as completed Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants