Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

npm7 下 addon 安装淘宝源和官方源的行为不一致 #1667

Closed
hyj1991 opened this issue Sep 24, 2021 · 8 comments · Fixed by #1675
Closed

npm7 下 addon 安装淘宝源和官方源的行为不一致 #1667

hyj1991 opened this issue Sep 24, 2021 · 8 comments · Fixed by #1675

Comments

@hyj1991
Copy link

hyj1991 commented Sep 24, 2021

复现步骤

  • npm i npm -g 将 npm 升级到最新 (当前是 7.24.1
  • npm set registry https://registry.npmjs.org 指向官方源
    • npm i xprofiler 安装成功
  • npm set registry https://registry.npm.taobao.org 指向淘宝源
    • npm i xprofiler 安装失败

失败信息

image


大致原因

npm7 指向官方源时,install 会根据返回信息正常使用 xprofiler 包的 package.json 定义的 install 脚本来安装:

node-pre-gyp install --fallback-to-build

这样就是正常安装。

npm7 指向淘宝源时,install 返回的信息里 package.json 定义的 install 为空,所以链到 cli 默认的 node-gyp rebuild 来安装 addon 导致失败。


更多信息

使用 npm6 及以下的 npm cli 安装不管是官方源还是淘宝源都是正常的。

@fengmk2
Copy link
Member

fengmk2 commented Nov 7, 2021

看来又是精简 json 返回的数据有问题

npmmirror

curl -v https://registry.npmmirror.com/xprofiler -H 'accept: application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, /' |json|less

image

npm 官方,多了一个 "hasInstallScript": true

image

@fengmk2
Copy link
Member

fengmk2 commented Nov 7, 2021

npm/arborist@1e5ac30

@fengmk2
Copy link
Member

fengmk2 commented Nov 7, 2021

@fengmk2
Copy link
Member

fengmk2 commented Nov 7, 2021

npm/registry#16

fengmk2 added a commit that referenced this issue Nov 7, 2021
avoid npm abbreviated version fields change

closes #1667
fengmk2 added a commit that referenced this issue Nov 7, 2021
avoid npm abbreviated version fields change

closes #1667

and starting use the new domain: npmmirror.com
@fengmk2
Copy link
Member

fengmk2 commented Nov 7, 2021

@hyj1991 fixed now

npm i xprofiler --registry=https://registry.npmmirror.com

added 92 packages in 4s

tree node_modules/xprofiler
node_modules/xprofiler
├── LICENSE
├── README.md
├── bin
│   ├── xprofctl
│   └── xprofctl.json
├── binding.gyp
├── build
│   └── binding
│       └── Release
│           └── node-v93-darwin-x64
│               └── xprofiler.node
├── index.d.ts
├── lib
│   ├── clean.js
│   ├── configure.js
│   ├── utils.js
│   └── xctl.js
├── package.json

@fengmk2
Copy link
Member

fengmk2 commented Mar 20, 2022

libc cnpm/npminstall#386

@kamilic
Copy link

kamilic commented Apr 7, 2022

我这边发现 npm 8 也是一样的问题,在安装 xprofiler 时必须要指定官方的源才能安装成功。
@fengmk2 这个修改是上线了吗?

@kamilic
Copy link

kamilic commented Apr 7, 2022

我对比了下,就是缺少了 "hasInstallScript": true 的问题

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants