TypeScript无法编译npm模块

时间:2017-03-15 10:06:59

标签: typescript npm

我有一个角度项目,它依赖于npm模块'module1'。当我为该模块ln -s module1创建了sysmlink时,我就可以在我的prject中使用它,例如 - import *作为来自“module1”的测试。当我删除符号链接并将其安装在node_modules中时,如npm install module1 --save并运行我的应用程序,我收到以下错误:

[11:16:00] E/launcher - Error: C:\Projects\Project\node_modules\module1\index.ts:1
(function (exports, require, module, __filename, __dirname) { export * from "./src/test.po";
                                                              ^^^^^^
SyntaxError: Unexpected token export
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Projects\Project\node_modules\ts-node\src\index.ts:303:16)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Projects\Project\features\steps\mytest.ts:1:1)
[11:16:00] E/launcher - Process exited with error code 100

请问您如何解决问题? (我需要在我的项目中安装module1以及如何访问和使用* .po.ts文件)谢谢。

index.ts:

export * from "./src/test1.po";

export * from "./src/test2.po";

export * from "./src/test3.po";

test1.po.ts:

import { browser, element, by } from "protractor";

export class test1{

    login( username: string, password: string ) {
...
    }
}

0 个答案:

没有答案