npm ERR! notsup Unsupported platform for n@9.0.0: wanted {“os“:“!win32“,“arch“:“any“} (current: {“os

出现场景:

执行 npm install -g n 时,本意是借助n模块去更新node版本,出现npm ERR! notsup Unsupported platform for n@9.0.0: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})

D:\testItem>npm install -g n
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for n@9.0.0: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    !win32
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\yuming.w.DIGQUANT\AppData\Roaming\npm-cache\_logs\2022-10-13T05_54_00_122Z-debug.log

看了一位网友的解决办法是直接在后面--force

npm install -g n --force
D:\testItem>npm install -g n --force
npm WARN using --force I sure hope you know what you are doing.
C:\Users\yuming.w.DIGQUANT\AppData\Roaming\npm\n -> C:\Users\yuming.w.DIGQUANT\AppData\Roaming\npm\node_modules\n\bin\n
+ n@9.0.0
updated 1 package in 0.667s

运行成功之后,再次执行n -v 会出现'"bash"' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

说明这个模块不支持当前操作系统,所以npm install -g n不能在windows下执行。其实我的目的是使用n模块来升级nodejs。在windows下升级noedjs直接下载安装即可,可以直接前往Download | Node.js官网下载node的指定版本即可。无须n模块。

当然还看到一个网友的另外一种解决方式,就是可以使用git上的一个工具gnvm来替换这个n模块

下载地址:https://github.com/Kenshin/gnvm

这种方式我暂时还没有试过,有兴趣的小伙伴可以去试试!

  • 14
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值