简体   繁体   中英

How do I install jest?

Been trying to install jest with this command:

npm i --global jest

and get these messages:

npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/Users/GRW/.nvm/versions/node/v6.11.1/bin/jest -> /Users/GRW/.nvm/versions/node/v6.11.1/lib/node_modules/jest/bin/jest.js
npm WARN jsdom@16.4.0 requires a peer of canvas@^2.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.3.1 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.3.1 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.

+ jest@26.4.2
updated 1 package in 32.731s

Have tried manually installing peer dependencies with:

npm i --save --global canvas@^2.5.0
npm i --save --global bufferutil@^4.0.1
npm i --save --global utf-8-validate@^5.0.2

but still am unable to install jest .

How do I install jest ?

EDIT : Forget about the global install and the peer dependency warnings go away, but I still get: -bash: jest: command not found

Since I seemed to have a prior installation of nvm that kept installations of different versions of node in different directories, I decided to start fresh.

Uninstalled and deleted jest , node , npm , and nvm .

Reinstalled node / npm , and was able to install jest and get the jest -v command to work properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM