-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support node.js ? ReferenceError: window is not defined #297
Comments
降为3.2.1;在首行加上global.window = this试试 |
这种线上打包 还要手动更改node_modules 包, 太不友好了 |
在node中使用可以这样用 |
加 global.window = this 可用 |
今天也遇到了这个问题mock模拟数据时使用了jsencrypt加密出现的版本3.3.2 import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
let decrypt = new JSEncrypt() 解决方式:在jsencrypt.min.js文件中添加如下代码 const window=this |
Because import (async () => {
global.window = this;
const JSEncrypt = await import('jsencrypt');
const jsencrypt = new JSEncrypt.default();
jsencrypt.setPublicKey(publicKey); // u public key
console.log(`token:\r\n${jsencrypt.encrypt(RSA_VALUE)}`);
})(); |
v16.19.1
3.3.2
The text was updated successfully, but these errors were encountered: