设置engines似乎没什么用?

设置engines似乎没什么用?

图片描述

不设置这个似乎也没什么影响?
所以这参数到底干嘛的。。。

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
提问者 demonCry 2023-08-10 12:47:23

> https://docs.npmjs.com/cli/v9/configuring-npm/package-json#engines


You can specify(指定) the version of node that your stuff works on:


```json

{


  "engines": {


    "node": ">=0.10.3 <15"


  }


}

```


And, like with dependencies, if you don't specify(指定) the version (or if you specify(指定) "*" as the version), then any version of node will do.


You can also use the "engines" field to specify(指定) which versions of npm are capable of properly installing your program. For example:


```json

{


  "engines": {


    "npm": "~1.0.20"


  }


}

```


Unless the user has set the [`engine-strict` config](https://docs.npmjs.com/cli/v9/using-npm/config#engine-strict) flag, 

this field is advisory only and will only produce <font color='orange'>warnings</font> when your package is installed as a dependency.

Brian 2023-08-10 09:49:30

用于指定运行环境,可以不用。

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
前端高级工程师(大前端)
  • 参与学习       303    人
  • 解答问题       391    个

全新打造“技术成长&职业破局”双高体系,深度打通“全栈 + 全流程 +多端+ 提效+AI赋能”,递进式锤炼思维与高阶技能,高效实现能力跃迁,助力成为“驾驭全局,深广兼备,打通多端全栈”的高级工程师

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师