Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何包含Angular 2项目中明确键入的文件_Javascript_Angularjs_Node.js_Typescript_Npm - Fatal编程技术网

Javascript 如何包含Angular 2项目中明确键入的文件

Javascript 如何包含Angular 2项目中明确键入的文件,javascript,angularjs,node.js,typescript,npm,Javascript,Angularjs,Node.js,Typescript,Npm,我正在开发angular 2/node.js应用程序,目前正在尝试为该项目安装打字。以前,当我运行服务器并启动typscript编译器时,我会得到以下日志: bash-3.1$ npm start > support-dashboard@1.0.0 start c:\MEAN_project > concurrently "npm run tsc:w" "node server.js" [1] Magic happens on port 8080 [0] [0] > sup

我正在开发angular 2/node.js应用程序,目前正在尝试为该项目安装打字。以前,当我运行服务器并启动typscript编译器时,我会得到以下日志:

bash-3.1$ npm start

> support-dashboard@1.0.0 start c:\MEAN_project
> concurrently "npm run tsc:w" "node server.js"

[1] Magic happens on port 8080
[0]
[0] > support-dashboard@1.0.0 tsc:w c:\MEAN_project
[0] > tsc -w
[0]
[0] node_modules/angular2/platform/browser.d.ts(78,90): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/application_ref.d.ts(38,88): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/application_ref.d.ts(92,42): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/application_ref.d.ts(151,33): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/change_detection/differs/default_keyvalue_differ.d.ts(23,15): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/change_detection/differs/default_keyvalue_differ.d.ts(25,16): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/di/reflective_provider.d.ts(103,123): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/di/reflective_provider.d.ts(103,165): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/core/linker/component_resolver.d.ts(8,53): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/linker/component_resolver.d.ts(12,44): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/linker/dynamic_component_loader.d.ts(59,148): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/linker/dynamic_component_loader.d.ts(100,144): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/linker/dynamic_component_loader.d.ts(105,139): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/core/linker/dynamic_component_loader.d.ts(106,135): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.
[0] node_modules/angular2/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.
[0] node_modules/angular2/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/collection.d.ts(100,41): error TS2304: Cannot find name 'Set'.
[0] node_modules/angular2/src/facade/collection.d.ts(101,22): error TS2304: Cannot find name 'Set'.
[0] node_modules/angular2/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'.
[0] node_modules/angular2/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'.
[0] node_modules/angular2/src/facade/lang.d.ts(71,59): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'.
[0] node_modules/angular2/src/platform/browser/browser_adapter.d.ts(75,33): error TS2304: Cannot find name 'Map'.
[0] node_modules/angular2/src/platform/dom/dom_adapter.d.ts(85,42): error TS2304: Cannot find name 'Map'.
[0] node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'.
[0] node_modules/rxjs/Observable.d.ts(66,60): error TS2304: Cannot find name 'Promise'.
[0] node_modules/rxjs/Observable.d.ts(66,70): error TS2304: Cannot find name 'Promise'.
[0] 8:52:59 AM - Compilation complete. Watching for file changes.
我在网上搜索,发现我可以使用typings CLI工具来安装typings定义;但是,当我试图通过postinstall从typings.json文件安装软件包时,出现了错误

我发现另一种方法是使用github中的库,从“确定键入”中复制es6-promise.d.ts,并将其添加到项目的根目录中,然后按照指示再次运行服务器。这一次,有关Promise未被发现的消息消失了


我没有弄清楚哪些.ts文件包含“Map”、“Set”和“Map constructor”的定义为了使typescript编译器能够找到这些库,我应该包含哪些文件?

如果库中不包含打字,您可以使用npm安装它们:

npm install d3 --save
npm install @types/d3 --save-dev

npm中包含所有类型定义