最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it a good practice to use in package.json '*' instead of a certain version of library of &#3

programmeradmin0浏览0评论

I passed one learning course on Node.js and Angular. And the teacher there used in package.json

A lot of asterisks instead of specific versions of libs.

"dependencies": {
    "bcrypt": "*",
    "bcryptjs": "^2.4.3",
    "body-parser": "*",
    "cors": "*",
    "express": "*",
    "jsonwebtoken": "*",
    "mongoose": "*",
    "morgan": "^1.10.0",
    "passport": "*",
    "passport-jwt": "*"
  },
  "devDependencies": {
    "nodemon": "^2.0.7"
  }

Is it a good or a bad practice to use them?

I passed one learning course on Node.js and Angular. And the teacher there used in package.json

A lot of asterisks instead of specific versions of libs.

"dependencies": {
    "bcrypt": "*",
    "bcryptjs": "^2.4.3",
    "body-parser": "*",
    "cors": "*",
    "express": "*",
    "jsonwebtoken": "*",
    "mongoose": "*",
    "morgan": "^1.10.0",
    "passport": "*",
    "passport-jwt": "*"
  },
  "devDependencies": {
    "nodemon": "^2.0.7"
  }

Is it a good or a bad practice to use them?

Share Improve this question edited Nov 16, 2021 at 5:20 Suraj Rao 29.6k11 gold badges95 silver badges104 bronze badges asked Nov 16, 2021 at 5:10 Tatyana MolchanovaTatyana Molchanova 1,6435 gold badges13 silver badges24 bronze badges 2
  • No it is not good practice. Why? new upgrade, your code relies on previous version. They change syntax and boom.... your code does not run. – epascarello Commented Nov 16, 2021 at 5:17
  • One or more having breaking changes and its chaos – Suraj Rao Commented Nov 16, 2021 at 5:19
Add a ment  | 

1 Answer 1

Reset to default 6

Wildcard is a bad idea. It says load the latest version no matter what. Sounds like a good idea so you do not have to keep updating. It is great until they introduce breaking changes into the api.

If they update from v1.5 to v2.0 and they changed their api, your code that relies on 1.5 syntax will no longer work in v2.0 if it is not backwards patible. Do this with multiple packages and you have a huge mess on your hands.

Some people will allow the minor version to be wildcard, but most people lock it down and manually upgrade so it can be fully tested.

https://docs.npmjs./about-semantic-versioning

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论