kittencup / angular2-ama-cn

angular2 随便问
691 stars 101 forks source link

ng2中如何使用node的包? #120

Closed lewgun closed 8 years ago

lewgun commented 8 years ago

如: var crypto = require('crypto'); ... function aesEncrypt(text, secKey) { var cipher = crypto.createCipheriv('AES-128-CBC', secKey, '0102030405060708'); return cipher.update(text, 'utf-8', 'base64') + cipher.final('base64'); } 这段代码如何才能在ng2中使用:

我已经进行的步骤如下:

  1. tsd insall node //安装node.d.ts
  2. import * as crypto from 'crypto'
  3. function aesEncrypt(...) {}

编译时出现错误: ... Uncaught SyntaxError: Unexpected token < Evaluating http://localhost:3000/crypto ...

thx