在gulp和nodejs中使用Typescript时需要和导出的未定义引用

我曾经写我的Web应用程序在纯JavaScript,直到我去了解Typescript。 它是一个JavaScript的超集,我没有任何问题,如果我编写和编译它,并使用我的WAMP服务器执行它。

但是我听说了angular2(我知道angular1),我开始学习它使用https://www.lynda.com/AngularJS-tutorials/Learn-AngularJS-2-Basics/428058-2.html课程。

他使用nodejsgulpgulp -webserver 。 我做了精确的设置,但最后我得到了

Uncaught ReferenceError:导出未定义@ animal.ts:1。
未捕获的ReferenceError:require未定义@ cat.ts:1

然后,我切换到第一次学习如何设置吞咽环境从https://www.youtube.com/watch?v=7xOubdqyqaY

这里是我的项目目录结构:

typescript/ |--app/ ----index.html, load animal.js, cat.js from js/ ----|--js, contains all compiles js files( animal.js, cat.js ) -------|--lib, contains all library files |--node_modules/ |--typescript/, contains my written typescript files ---|--animal.ts ---|--cat.ts |--typing/s, contains typescript definition files |--gulp.config.js |--gulpfile.js |--package.json |--tsconfig.json |--tslint.json 

当我运行命令cmd在根文件夹(typescript)的gulp命令,它运行所有的任务,它编译所有ts文件,皮棉,并使用浏览器同步superstatic服务 。 不过,我得到同样的错误

Uncaught ReferenceError:导出未定义@ animal.ts:1。
未捕获的ReferenceError:require未定义@ cat.ts:1

我的文件内容:

animal.ts

 export class Animal { constructor( private name: string, private sound: string ) { } makeSound() { console.log( `${this.name} makes ${this.sound}` ); } } let a: Animal = new Animal( "tiger33", "Gurrrrrr" ); a.makeSound(); 

cat.ts

 import {Animal} from "./animal" let b: Animal = new Animal( "Cat", "Mewww" ); b.makeSound(); 

请告诉我我做错了什么。 我在全球安装了nodegulptsc 。 我是否需要安装browserifyrequireJS ,但在video中,他们没有使用任何这些。 谢谢

最后让它使用Browserify工作。

这里的步骤。