angular 2 webpack 2错误找不到名字'global'

时间:2017-04-11 15:58:55

标签: angular typescript webpack webpack-2 ts-loader

我正在尝试使用webpack 2设置角度2 但是我遇到了构建错误。

我刚刚导入了@ angular / platform-b​​rowser-dynamic 但它在屏幕上显示很多错误。找不到模块'错误找不到名字'全球'。'是其中之一

C:\ Users \ T12449 \ Desktop \ angular \ hello-angular \ node_modules \ zone.js \ lib \ zone-spec \ wtf.ts中的错误 (156,80):错误TS2304:找不到名称'global'。

C:\ Users \ T12449 \ Desktop \ angular \ hello-angular \ node_modules \ zone.js \ lib \ zone-spec \ fake-async-test.ts中的错误 (268,80):错误TS2304:找不到名称'global'。

C:\ Users \ T12449 \ Desktop \ angular \ hello-angular \ node_modules \ zone.js \ lib \ node \ node.ts中的错误 (18,93):错误TS2304:找不到名称'global'。

我的webpack.config.js

module.exports = {
   entry: './src/main.ts',
   output: {
   filename: '[name].[ext]'
 },
 resolve: {
  extensions: ['.ts', '.tsx', '.js']
 },
 module: {
  loaders: [
    { test: /\.tsx?$/, loader: 'ts-loader' }
   ]
 }
}

package.json

{
  "name": "hello-angular",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack"
    },
  "author": "",
  "license": "ISC",
  "devDependencies": {
  "@types/core-js": "^0.9.41",
  "ts-loader": "^2.0.3",
  "typescript": "^2.2.2",
  "webpack": "^2.3.3",
  "webpack-dev-server": "^2.4.2"
},
"dependencies": {
    "@angular/common": "^4.0.1",
    "@angular/compiler": "^4.0.1",
    "@angular/core": "^4.0.1",
    "@angular/platform-browser": "^4.0.1",
    "@angular/platform-browser-dynamic": "^4.0.1",
    "rxjs": "^5.0.1",
    "zone.js": "^0.8.4"
  }
}

main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
const a :number = 0;

tsconfig.json

{
  "compilerOptions": {
    "removeComments": true,
    "sourceMap": false,
    "module": "commonjs",
    "noImplicitAny": false,
    "target": "es2015",
    "typeRoots": [
      "../node_modules/@types"
    ],
    "types": [
      "core-js"
    ]
},
"exclude": [
  "../node_modules"
]
}

1 个答案:

答案 0 :(得分:2)

您是否尝试过设置:

 mypage.zbl

<FormField z-of="ItemPicker" Id="Type" LabelText="Type" 
  Control.AllowNull="true"
  Control.DataSource="@(Database.GetList&lt;ContactType&gt;())" />

myentity

public partial class Contact : GuidEntity
{
   public string Name { get; set; }

}

使用:

typings.d.ts

如下所述:https://github.com/angular/angular-cli#3rd-party-library-installation