node.js - NPM 安装与 package.json 不同的版本

标签 node.js npm npm-install pixi.js

对于我们的 Electron 应用程序,我们需要特定版本的 pixi.js (5.0.0-rc.3)。因此,我们在 package.json 中指定了 "pixi.js": "^5.0.0-rc.3",

当我们现在运行 npm install 并打开我们的应用程序时,pixi 会显示欢迎消息,package-lock.json 状态版本为 5.0.4。我们尝试删除 node_modules 文件夹并重新安装所有模块,但版本仍然错误。

我们在 html 文件中的导入语句是 const PIXI = require('pixi.js'); 如果我没有记错的话,这应该会获取本地安装的 pixi 版本。

这是一个错误吗?或者是故意的(如果是,是什么目的)?

更新

由于现在有一些答案和评论,这是我们迄今为止进一步尝试的:

  • 删除 package-lock.json、node_modules 文件夹(本地和全局)并再次运行 npm i
  • 重新安装 NodeJS (LTS)
  • 使用当前版本的 NodeJS 测试了所有内容
  • 从 package.json 中删除了“^”,因为安装范围内的任何版本都可以
  • 在另一台 Windows 10 计算机和 macOS 上进行了测试

更新2

现在有三个答案,但到目前为止没有一个可以解决问题,我开始相信这不是我的错,但可能是 Pixi JS 的错误。我打开了一个问题on their GitHub page ,也许他们可以提供帮助。

最佳答案

如果您想安装特定版本,请不要在 package.json 中使用 ~^,请准确使用版本

The tilde ~ matches the most recent patch version (the third number) for the specified minor version (the second number).
~1.2.3 will match all 1.2.x versions but will hold off on 1.3.0.

The caret ^ is more relaxed. It matches the most recent minor version (the second number) for the specified major version (the first number).
^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0.

在您的情况下:“pixi.js”:“5.0.0-rc.3”

来自:What's the difference between tilde(~) and caret(^) in package.json?

关于node.js - NPM 安装与 package.json 不同的版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56805264/

相关文章:

npm - 在Atom中安装软件包依赖项

node.js - npm 命令行工具的状态保存在哪里?

node.js - 如何在文件夹中安装npm

npm - `npm update` 和 `remove package-lock.json` 加上 `npm install` 之间的区别?

javascript - npm:从现有依赖树添加依赖

javascript - REST API 与 Postgresql - 如何制作最简单的前端界面

javascript - req.session undefined with express 和 connect-redis

javascript - 模块之间不持久的解构变量值

node.js - 如何删除旧版本的 node/npm?

node.js - npm 启动错误(spawn ENOENT,在 nodetest1@0.0.0 启动脚本失败。)