如何安装jest?

问题描述 投票:0回答:2

一直在尝试使用以下命令安装jest

npm i --global jest

并获取这些消息:

npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: 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 [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: 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 [email protected] requires a peer of canvas@^2.5.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.

+ [email protected]
updated 1 package in 32.731s

已尝试手动安装对等依赖项:

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

但仍然无法安装jest

如何安装jest

编辑:忘记全局安装和对等依赖警告消失,但我仍然得到: -bash:开玩笑:找不到命令

npm jestjs
2个回答
0
投票

由于我之前似乎安装了 nvm,并将不同版本的 node 安装在不同的目录中,因此我决定重新开始。

已卸载并删除 jestnodenpmnvm

重新安装了 node/npm,并且能够安装 jest 并让

jest -v
命令正常工作。


0
投票

你试过这个吗?

sudo npm install -g jest
© www.soinside.com 2019 - 2024. All rights reserved.