问题描述
构建节点服务时收到以下警告。
DeprecationWarning: crypto.createCipher is deprecated.
我的服务中安装了crypto npm模块。
import crypto from 'crypto';
但是问题是,使用 crypto.createCipher 函数在服务中我无处可去。
我在加密服务中使用的唯一功能是crypto.randomBytes(32).toString('hex');
我尝试过的事情
我尝试重新安装最新版本的加密模块(无法解决警告)
解决方法
您不应使用此crypto npm软件包。
修复
您需要使用内置的crypto
软件包。无需安装。默认情况下是内置的。
请从您的crypto
中删除package.json
npm软件包
npm remove --save crypto