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 > [email protected]: Package no longer supported. Contact [email protected] for more info.
[2/4] 馃殮 Fetching packages...
error [email protected]: 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.
Should be able to install enzyme with enzyme-adapter-react-16 successfully
| library | version
| ---------------- | -------
| Enzyme | Latest
| React | Latest / v16.3.2
Looks like this issue has been addressed / fixed in https://github.com/facebook/create-react-app/issues/4367
Either way, "engines" is advisory; yarn shouldn't be failing on it.
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
@jhbsk, I followed instructions but still getting the same error with yarn install it seems to be fixed when npm install is used
npm 6.1.0
node 10.3.0
yarn 1.7.0 // <= problem began after upgrading
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?
@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.
Very good points @paneq & @kahboom. The problem is caused by upath v1.0.4 as a deep dependency of webpack see PR here that fixed this which has a nice dependency tree in the description.
So you might just be able to get away with updating webpack with:
yarn upgrade [email protected]
This should cause all the dependencies to be updated, but I've not tried it so do let me know how it goes!
@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"
:-)
@paneq Thanks for this. I noticed that you can also delete yarn.lock and run yarn again.
@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 ?
Or you can always downgrade to older version of node earlier than 9
@paneq thanks a lot , it solves my problem
@paneq unbelivable - you mad my day!
@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.lockand 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":-)
@paneq thanks a lot , it solves my problem
can't we just use package.json "resolutions": { "upath": "1.1.0" }?
yup, it works. (on yarn)
@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.lockand 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":-)
hi i am deploying on server with jenkins and i got this error.should i edit yarn.lock and commit in pipeline?
Most helpful comment
@kahboom @jhbsk
Here is a trick I learned recently:
Find
in
yarn.lockand remove it manually. Just these 4 lines.Run
yarn install.Watch how only this 1 package got upgraded to:
:-)