|
| 1 | +We encountered the same issue when updating a legacy project depending on `[email protected]` to Node.js 12+. |
| 2 | + |
| 3 | +These fixes enable you to use Node.js 12+ with `[email protected]` by overriding `graceful-fs` to version `^4.2.4`. |
| 4 | + |
| 5 | +If you are using yarn v1 |
| 6 | +------------------------------------------------------------ |
| 7 | +Yarn v1 [supports resolving a package to a defined version][2]. |
| 8 | +You need to add a `resolutions` section to your `package.json`: |
| 9 | +```json |
| 10 | +{ |
| 11 | + // Your current package.json contents |
| 12 | + "resolutions": { |
| 13 | + "graceful-fs": "^4.2.4" |
| 14 | + } |
| 15 | +} |
| 16 | +``` |
| 17 | +Thanks [@jazd][3] for this way to solve the issue. |
| 18 | + |
| 19 | +If you are using npm |
| 20 | +-------------------------------------------------------- |
| 21 | +Using [`npm-force-resolutions`][4] as a preinstall script, you can obtain a similar result as with yarn v1. You need to modify your package.json this way: |
| 22 | +```json |
| 23 | +{ |
| 24 | + // Your current package.json |
| 25 | + "scripts": { |
| 26 | + // Your current package.json scripts |
| 27 | + "preinstall": "npx npm-force-resolutions" |
| 28 | + }, |
| 29 | + "resolutions": { |
| 30 | + "graceful-fs": "^4.2.4" |
| 31 | + } |
| 32 | +} |
| 33 | +``` |
| 34 | +`npm-force-resolutions` will alter the `package-lock.json` file to set `graceful-fs`to the wanted version before the `install` is done. |
| 35 | + |
| 36 | +If you are using a custom `.npmrc` file in your project and it contains either a proxy or custom registry, you might need to change `npx npm-force-resolutions` to `npx --userconfig .npmrc npm-force-resolutions` because as of now, `npx` doesn't use the current folder `.npmrc` file by default. |
| 37 | + |
| 38 | +Origin of the problem |
| 39 | +--------------------- |
| 40 | +This issue stems from the fact that `[email protected]` [depends ][5] on `graceful-fs@^3.0.0` which monkeypatches Node.js `fs` module. |
| 41 | + |
| 42 | +This used to work with Node.js until version 11.15 (which is a [version][6] from a development branch and shouldn't be used in production). |
| 43 | + |
| 44 | +[`graceful-fs@^4.0.0`][7] does not monkeypatch Node.js `fs` module anymore, which makes it compatible with Node.js > 11.15 (tested and working with versions 12 and 14). |
| 45 | + |
| 46 | +Note that this is not a perennial solution but it helps when you don't have the time to update to `gulp@^4.0.0`. |
| 47 | + |
| 48 | + |
| 49 | + [1]: https://docs.npmjs.com/files/shrinkwrap.json |
| 50 | + [2]: https://classic.yarnpkg.com/en/docs/selective-version-resolutions/ |
| 51 | + [3]: https://stackoverflow.com/users/1650473/jazd |
| 52 | + [4]: https://github.com/rogeriochaves/npm-force-resolutions |
| 53 | + [5]: https://github.com/gulpjs/gulp/blob/v3.9.1/package.json#L47 |
| 54 | + [6]: https://nodejs.org/en/about/releases/ |
| 55 | + [7]: https://github.com/isaacs/node-graceful-fs#v4 |
0 commit comments