angularjs 2 with webpack

Datetime:2016-08-23 00:27:31          Topic: AngularJS  Webpack           Share

when trying to set my angular2 project with webpack but after I run npm install its giving me below errors, there is imported everything from angularjs guide (https://angular.io/docs/ts/latest/guide/webpack.html):

chunk {0} app.js (app) 1.98 kB {2} [rendered]

chunk {1} polyfills.js (polyfills) 586 kB

chunk {2} vendor.js (vendor) 2.47 MB {1}

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/core/testing/mock_application_ref.d.ts

(12,33): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/rxjs/operator/toPromise.d.ts

(7,59): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/rxjs/observable/PromiseObservable.d.ts

(22,31): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/rxjs/observable/PromiseObservable.d.ts

(23,26): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/router/src/router.d.ts

(162,43): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/router/src/router.d.ts

(178,59): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/http/src/url_search_params.d.ts

(11,16): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/http/src/headers.d.ts(43,59): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/platform-browser/src/dom/dom_renderer.d.ts

(10,37): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/platform-browser/src/facade/promise.d.ts

(13,43): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/platform-browser/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/platform-browser/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/platform-browser/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/platform-browser/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/platform-browser/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/common/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/core/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/core/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/core/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/core/src/linker/component_resolver.d.ts(9,58): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/node_modules/@angular/core/src/linker/component_resolver.d.ts(13,49): error TS2304: Cannot find name 'Promise'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/src/app/app.component.ts(5,13): error TS2304: Cannot find name 'require'.

ERROR in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/src/app/app.component.ts(6,12): error TS2304: Cannot find name 'require'.

ERROR in ./src/polyfills.ts(3,1): error TS2304: Cannot find name 'require'.

ERROR in ./src/polyfills.ts(4,5): error TS2304: Cannot find name 'process'.

ERROR in ./src/polyfills.ts(9,3): error TS2304: Cannot find name 'require'.

ERROR in ./src/main.ts(4,5): error TS2304: Cannot find name 'process'.

ERROR in ./src/app/app.component.js

Module not found: Error: Cannot resolve 'file' or 'directory' ../../public/css/styles.css in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/src/app

@ ./src/app/app.component.js 12:0-38

ERROR in ./src/app/app.component.html

Module not found: Error: Cannot resolve 'file' or 'directory' ../../public/images/angular.png in /Users/dheerajagrawal/newenv/backend/mycontactid/static/v4/beta/src/app

@ ./src/app/app.component.html 1:93-135

Child html-webpack-plugin for "index.html":

chunk {0} index.html 301 bytes

webpack: bundle is now VALID.

my component file is:

import { Component } from '@angular/core';

import '../../public/css/styles.css';

@Component({

selector: 'my-app',

template: require('./app.component.html'),

styles: [require('./app.component.css')]

})

export class AppComponent { }

Solution :

Added Package.json file in the application folder and add list of dependency in that file. After that in command prompt go to application folder location and run npm install. it should work fine.





About List