Windows 10 x64
ng 2.4.4
nodejs 6.9.2
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"
]
}
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
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.
You should be able to use typings.d.ts as described in https://github.com/angular/angular-cli#3rd-party-library-installation with the following content:
declare var global: any
Before I was checking my ng cli project I followed the link to the repo provided by @filipesilva and the 3rd party section isn't there anymore. However that's not an issue because it used to tell you that you should create a typings.d.ts in your src directory which fortunately ng new creates for you anyway.
So TL;DR; just go to src/typings.d.ts and add the declare var global: any to it.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
You should be able to use
typings.d.tsas described in https://github.com/angular/angular-cli#3rd-party-library-installation with the following content: