【发布时间】:2019-11-20 16:15:59
【问题描述】:
我尝试使用 crypto-js 在 react typescript run with docker compose 中使用,但出现以下错误
找不到模块:无法解析“/app/crypto”中的“crypto-js”
这是我导入的crypto-js。例如:
import crypto from 'crypto-js';
export const encrypt = (key: string, evalue: any) => {
const secret_key = crypto.SHA256(key);
return crypto.AES.encrypt(evalue, secret_key).toString();
};
我试了很多次,还是不行。
【问题讨论】:
-
你能给我们看看你的
tsconfig文件吗?另外,您是否已经在项目中使用了其他 node_modules? -
是的,这是我的 tsconfig 文件:``` { "compilerOptions": { "target": "es5", "lib": [ "dom", "dom.iterable", "esnext " ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "module": "esnext", "moduleResolution" :“节点”,“resolveJsonModule”:真,“isolatedModules”:真,“noEmit”:真,“jsx”:“反应”},“包括”:[“src”]}```
标签: reactjs typescript encryption docker-compose cryptojs