问题描述
运行命令 npm install gatsby-plugin-google-tagmanager
我尝试通过运行 npm update -g
来更新 npm 版本,但是当我检查它时,它仍然是“6.14.6”。
任何帮助将不胜感激,谢谢。
npm WARN notsup Unsupported engine for gatsby-plugin-google-tagmanager@3.4.0: wanted: {"node":">=12.13.0"} (current: {"node":"10.22.0","npm":"6.14.6"})
npm WARN notsup Not compatible with your version of node/npm: gatsby-plugin-google-tagmanager@3.4.0
npm WARN gatsby-plugin-google-tagmanager@3.4.0 requires a peer of gatsby@^3.0.0-next.0 but none is installed. You must install peer dependencies yourself.
npm WARN gatsby-plugin-google-tagmanager@3.4.0 requires a peer of react@^16.9.0 || ^17.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN gatsby-plugin-google-tagmanager@3.4.0 requires a peer of react-dom@^16.9.0 || ^17.0.0 but none is installed. You must install peer dependencies yourself.
+ gatsby-plugin-google-tagmanager@3.4.0
updated 1 package and audited 3 packages in 0.68s
found 0 vulnerabilities
解决方法
需要更新的不是 npm,而是 Node.js。您运行的是 Node.js 10.22.0,但包 gatsby-plugin-google-tagmanager@3.4.0
需要 Node.js 12.13.0 或更高版本。
鉴于对 Node.js 10.x 的支持在几天前(2021 年 4 月 30 日)结束,这是更新的另一个原因。目前,我建议更新到 14.x,这是最新的 LTS(长期支持)版本。不过,12.x 很好,并且会得到另外 12 个月的支持。 (14.x 将再受支持 24 个月。16.x 将再受支持 36 个月,但直到 10 月才正式成为 LTS 版本,因此可能会发生许多在 LTS 版本中不会发生的更改.)
还值得注意的是,该软件包确实已安装。您收到了有关 Node.js 版本的警告,但没有收到错误消息。不过,我不建议尝试使用它声称不支持的 Node.js 版本运行该包。