弃用警告:node.js中不推荐使用crypto.createCipher

时间:2020-10-23 06:12:11

标签: node.js npm cryptography compiler-warnings

构建节点服务时收到以下警告。

DeprecationWarning: crypto.createCipher is deprecated.

我的服务中安装了crypto npm模块。

import crypto from 'crypto';

但是问题是,使用 crypto.createCipher 函数在服务中我无处可去。 我在加密服务中使用的唯一功能是crypto.randomBytes(32).toString('hex');

我尝试过的事情

我尝试重新安装最新版本的加密模块(无法解决警告)

1 个答案:

答案 0 :(得分:1)

您不应使用此crypto npm软件包。

![enter image description here




修复

您需要使用内置的crypto软件包。无需安装。默认情况下是内置的。

请从您的crypto中删除package.json npm软件包

npm remove --save crypto