Skip to content

Cannot find name 'global' #4196

@keyiis

Description

@keyiis

OS?

Windows 10 x64

Versions.

ng 2.4.4
nodejs 6.9.2

Repro steps.

main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
import {enableProdMode} from '@angular/core';
if (global['node_env'] !== 'development') {
    enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2015",
      "dom"
    ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  },
  "files": [
    "src/angular/app/app.module.ts",
    "src/angular/app/main.ts"
  ],
  "angularCompilerOptions": {
    "genDir": "aot",
    "skipMetadataEmit": true
  },
  "compileOnSave": false,
  "exclude": [
    "node_modules",
    "backup",
    "output"
  ]
}

The log given by the failure.

Normally this include a stack trace and some more information.

ERROR in ./src/angular/app/main.ts
Module build failed: Error: D:/work/nodejs/keypos/aot/src/angular/app/main.ts (4,5): Cannot find name 'global'.)
    at _checkDiagnostics (D:\work\nodejs\keypos\aot\node_modules\@ngtools\webpack\src\loader.js:145:15)
    at D:\work\nodejs\keypos\aot\node_modules\@ngtools\webpack\src\loader.js:172:17

Mention any other details that might be useful.

I run angular2 in electron,use jit compiler work fne,but when change to aot have failed, and i already add node typedefintion in typings
"node": "registry:dt/node#6.0.0+20160613154055",
already try npm i @types/node
finally,i get same error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions