简体   繁体   English

我如何安装 jest?

[英]How do I install jest?

Been trying to install jest with this command:一直在尝试使用以下命令安装jest

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 .但仍然无法安装jest

How do I install jest ?我如何安装jest

EDIT : Forget about the global install and the peer dependency warnings go away, but I still get: -bash: jest: command not found编辑:忘记全局安装和对等依赖警告消失,但我仍然得到: -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.由于我之前似乎安装了nvm ,它将不同版本的node安装保存在不同的目录中,因此我决定重新开始。

Uninstalled and deleted jest , node , npm , and nvm .卸载并删除jestnodenpmnvm

Reinstalled node / npm , and was able to install jest and get the jest -v command to work properly.重新安装node / npm ,并且能够安装jest并使jest -v命令正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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