官术网_书友最值得收藏!

Fixing bugs by updating package dependencies

Bugs exist in every piece of software. An update to the Node.js platform may break an existing package, as might an upgrade to packages used by the application. Your application may trigger a bug in a package it uses. In these and other cases, fixing the problem might be as simple as updating a package dependency to a later (or earlier) version.

First identify whether the problem exists in the package or in your code. After determining it's a problem in another package, investigate whether the package maintainers have already fixed the bug. Is the package hosted on GitHub or another service with a public issue queue? Look for an open issue on this problem. That investigation will tell you whether to update the package dependency to a later version. Sometimes, it will tell you to revert to an earlier version; for example, if the package maintainer introduced a bug that doesn't exist in an earlier version.

Sometimes, you will find that the package maintainers are unprepared to issue a new release. In such a case, you can fork their repository and create a patched version of their package.

One approach to fixing this problem is pinning the package version number to one that's known to work. You might know that version 6.1.2 was the last release against which your application functioned, and that starting with version 6.2.0 your application breaks. Hence, in package.json:

"dependencies": {
"module1": "6.1.2"
}

This freezes your dependency to the specific version number. You're free, then, to take your time updating your code to work against later releases of that module.  Once your code is updated, or the upstream project is updated, change the dependency appropriately.

Another approach is to host a version of the package somewhere outside of the npm repository. This is covered in a later section.

主站蜘蛛池模板: 娱乐| 勐海县| 罗源县| 靖西县| 黄冈市| 齐河县| 辽源市| 定西市| 斗六市| 韶关市| 武鸣县| 封丘县| 安仁县| 定州市| 丰顺县| 五原县| 海南省| 金坛市| 台北县| 平顺县| 永寿县| 武陟县| 阳东县| 吉隆县| 霍山县| 宾川县| 肥乡县| 玉山县| 渝北区| 永靖县| 花莲市| 霸州市| 新郑市| 信宜市| 铁岭市| 武义县| 颍上县| 沁水县| 布尔津县| 扎赉特旗| 屯留县|