【问题标题】:Unable to install npm /react /node js on mac terminal无法在 mac 终端上安装 npm /react /node js
【发布时间】:2021-06-18 16:22:52
【问题描述】:

我无法在我的 mac 终端或 VSTS 代码上运行 npm install。请参阅下面尝试运行的命令

  1. npm install -g vsts-npm-auth --registry https://registry.npmjs.com--always-auth false
  2. vsts-npm-auth -config .npmrc

这里有错误

第二个命令出现格式错误

vsts-npm-auth -config .npmrc zsh: exec format error: vsts-npm-auth 
  1. 运行:npm install
  2. 运行 npm start`

如您所见,我什至无法通过第一个命令。

我试过 清除代理 分配代理 而且我的网络完全没问题,我 ping https://registry.npmjs.com 并且它工作正常,我也这样做了

-npm config 设置注册表https://registry.npmjs.org/

npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.com--always-auth/vsts-npm-auth failed, reason: getaddrinfo ENOTFOUND registry.npmjs.com--always-auth
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

【问题讨论】:

  • 嗨@Pxaml,这里有更新吗?随时让我知道最新消息。
  • 不!我希望 。我最终使用了窗户。我想不通
  • 嗨@Pxaml,你能在这里分享最新的错误信息吗?有截图更好。谢谢。

标签: node.js npm azure-devops


【解决方案1】:

vsts-npm-auth 不支持 Linux/Mac。

来自Azure DevOps Documentation / Set up your client's npmrc

  1. 第一个选项是生成令牌

Set up authentication on your dev box / Linux or Mac

In the Project setup section, select Other

  1. 第二个选项是平台无关库

更好的-vsts-npm-auth

【讨论】:

  • better-vsts-npm-auth 在 macOS 上完美运行 - 如果您使用 .yarnrc.yml,也支持纱线 - 使用从 ~/.npmrc 生成的刷新令牌更新 npmAuthToken 属性
  • better-vsts-npm-auth 肯定是在 Mac IMO 上设置的最佳方式。
【解决方案2】:

--always-auth 之前缺少一个空格:

npm install -g vsts-npm-auth --registry https://registry.npmjs.com --always-auth false
# Space was missing here -----------------------------------------^

【讨论】:

  • 谢谢,我在第二个命令上也遗漏了一些东西 vsts-npm-auth -config .npmrc zsh: exec format error: vsts-npm-auth
猜你喜欢
  • 2021-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-20
  • 1970-01-01
  • 2016-03-04
  • 2021-01-18
  • 1970-01-01
相关资源
最近更新 更多