首页 文章

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

提问于
浏览
0

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

我刚刚导入了@ angular / platform-browser-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:找不到名称'全局” .

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 回答

相关问题