Is it possible to specify a npm module version without updating package.json?

huangapple go评论60阅读模式
英文:

Is it possible to specify a npm module version without updating package.json?

问题

I would like to override a npm module's version without changing the package.json file as I would like to avoid forking the repo, if possible.

If the package.json file looks something like

...
"dependencies": {
    "iwanttooverridethis": "2.5.0",
    ...

can I run a step like npm install --override "iwanttooverridethis=3.0.0" which would install version 3.0.0 of iwanttooverridethis instead of version 2.5.0? Or achieve the same result some other way?

英文:

I would like to override a npm module's version without changing the package.json file as I would like to avoid forking the repo, if possible.

If the package.json file looks something like

    ...
    "dependencies": {
        "iwanttooverridethis": "2.5.0",
        ...

can I run a step like npm install --override "iwanttooverridethis=3.0.0" which would install version 3.0.0 of iwanttooverridethis instead of version 2.5.0? Or achieve the same result some other way?

答案1

得分: 0

你可以使用 --no-save 标志来安装指定的 npm 包版本,而不更改 package.json 文件。请记住,这是临时的,当你运行 npm install 时,它将重置为 package.json 文件中指定的版本。示例:npm install yourpackage@3.0.0 --no-save

英文:

You should be able to use the --no-save flag to install the specified npm package version without changing the package.json file. Just keep in mind that this is temporary and will reset to the one specified in the package.json file when you run npm install. An example is npm install yourpackage@3.0.0 --no-save.

huangapple
  • 本文由 发表于 2023年4月4日 05:08:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75923785.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定