enzyme: Node v10.0.0 error Found incompatible module, upath@1.0.4: The engine "node" is incompatible with this module. Expected version ">=4 <=9"

Current behavior

Trying to install enzyme with the command yarn add enzyme enzyme-adapter-react-16 --dev fails in my environment with the following error:

(node:88766) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] šŸ”  Resolving packages...
warning enzyme > rst-selector-parser > nearley > nomnom@1.6.2: Package no longer supported. Contact support@npmjs.com for more info.
[2/4] 🚚  Fetching packages...
error upath@1.0.4: The engine "node" is incompatible with this module. Expected version ">=4 <=9".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

The deprecation warning is a separate / unrelated issue which started recently after upgrading to Yarn v1.6.0.

Expected behavior

Should be able to install enzyme with enzyme-adapter-react-16 successfully

Your environment

  • React v16.3.2
  • Node v10.0.0
  • NPM v5.6.0
  • Yarn v1.6.0

Version

library version
Enzyme Latest
React Latest / v16.3.2

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (1 by maintainers)

Most upvoted comments

@kahboom @jhbsk

Here is a trick I learned recently:

Find

upath@^1.0.0:
  version "1.0.4"
  resolved "https://registry.yarnpkg.com/upath/-/upath-1.0.4.tgz#ee2321ba0a786c50973db043a50b7bcba822361d"

in yarn.lock and remove it manually. Just these 4 lines.

Run yarn install.

Watch how only this 1 package got upgraded to:

 upath@^1.0.0:
  version "1.1.0"
  resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.0.tgz#35256597e46a581db4793d0ce47fa9aebfc9fabd"

😃

Yep, I didn’t want to use ā€œenginesā€ - that’s just a messy workaround.

Instead, the proper solution is to delete node_modules/, package-lock.json & yarn.lock and run yarn install or npm i again.

After doing this, the original command is now working: yarn add enzyme enzyme-adapter-react-16 --dev

Or you can always downgrade to older version of node earlier than 9

@paneq - exactly; it’s not a viable solution for me, as I work with a large team and we can’t just be deleting the yarn.lock file on a whim.

can’t we just use package.json "resolutions": { "upath": "1.1.0" }?

yup, it works. (on yarn)

Instead, the proper solution is to delete node_modules/, package-lock.json & yarn.lock and run yarn install

which would lead to forgetting all the locked versions and potentially upgrading the libraries?

@joonhocho Please see this comment https://github.com/airbnb/enzyme/issues/1637#issuecomment-396141921 and try to recall why we use yarn and yarn.lock in the first place? Perhaps to remember all locked versions of packages which get lost when you remove yarn.lock ?

@paneq Thanks for this. I noticed that you can also delete yarn.lock and run yarn again.