2

运行环境是 Node12,如何知道用 npm 安装依赖库时应该指定哪个版本号?

 1 year ago
source link: https://www.v2ex.com/t/908873
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  Node.js

运行环境是 Node12,如何知道用 npm 安装依赖库时应该指定哪个版本号?

  sdjl · 1 小时 20 分钟前 · 223 次点击

我对 node 不是很熟悉,微信小程序的云函数运行在 node12.16 上,但是我的开发电脑是 M1 的 Macbook ,本地安装的是 node16.

我发现,如果我用 npm 安装依赖库时不指定版本号,可能会出现在本地( node16 )正常运行,但上传到云环境(node12.16)后不能正常运行的情况。

我也想过在本地安装一个 node12 ,但发现在 M1 芯片的 Mac 上安装 node12 很麻烦。

所以,我想的是如果用 npm install 依赖库的时候,指定适合 node12.16 这个环境的版本号是不是可以解决问题?

或者,有没有其他更好的办法? 谢谢,我最近刚学用 node ,不是很了解。


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK