未分類 18 10 月 2020 vue + ts 中 import crypto from ‘crypto’ 失败,提示 Cannot find module ‘crypto’ or its corresponding type declarations. vue + ts 中 import crypto from ‘crypto’ 失败,提示 Cannot find module ‘crypto’ or its corresponding type declarations. 資深大佬 : Nicolay 2 请问大家该怎么办呢,我在 es6 的项目中这样写是没有问题的, 大佬有話說 (5) 主 資深大佬 : Nicolay package.json 中是这样写的 ,crypto-js 和 crypto 都需要用,虽然我不太懂二者的区别,不过 import cryptoJs from ‘crypto-js’ 没有问题,“dependencies”: { “@types/crypto-js”: “^3.1.47”, “@types/echarts”: “^4.8.1”, “axios”: “^0.19.0”, “crypto”: “^1.0.1”, “crypto-js”: “^4.0.0”, }, 資深大佬 : Timefly 缺少类型声明文件吧,或许还要装一个 @types/crypto,先去 npm 上看看有没有 主 資深大佬 : Nicolay @Timefly 这个的确没有, 資深大佬 : mxT52CRuqR6o5 用啥打包的,crypto 是 node 自带模块,打包器不帮你打包浏览器环境是运行不了的 主 資深大佬 : Nicolay @mxT52CRuqR6o5 webpack