使用导入abc时出现意外标识符= require('node
我有一个.ts文件
import abc = require('abc'); // example
module.exports = { ...
execute(test : abc.class ,args : Array<string>) { ...
当我运行代码时,IDE发送错误:
import abc = require('abc');
^^^
SyntaxError: Unexpected identifier
我无法使用const abc = require('abc'),因为““ abc”'没有默认的export.ts(1192)
回答如下:在打字稿中,您应该使用import {abc} from 'abc' //if no export default