-4

I upgraded from angular 2 to angular 4 and now I'm getting an error. I copied the text from this i.e.

npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save

Now I'm getting this error when I run npm start Please assist

`

product-management@1.0.0 start C:\Users\dp9\Documents\Visual Studio 2015\Projects\NG\NG UI

tsc && concurrently "tsc -w" "lite-server"

node_modules/@types/node/index.d.ts(70,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'main' must be of type 'any', but here has type 'NodeModule'.

node_modules/@types/node/index.d.ts(81,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'parent' must be of type 'any', but here has type 'NodeModule'.

node_modules/@types/node/index.d.ts(82,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'children' must be of type 'any[]', but here has type 'NodeModule[]'.

node_modules/@types/node/index.d.ts(102,6): error TS2300: Duplicate identifier 'BufferEncoding'.

node_modules/@types/node/index.d.ts(263,18): error TS2300: Duplicate identifier 'EventEmitter'.

node_modules/@types/node/index.d.ts(371,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'stdout' must be of type 'WritableStream', but here has type 'WriteStream'.

node_modules/@types/node/index.d.ts(372,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'stderr' must be of type 'WritableStream', but here has type 'WriteStream'.

node_modules/@types/node/index.d.ts(373,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'stdin' must be of type 'ReadableStream', but here has type 'ReadStream'.

node_modules/@types/node/index.d.ts(422,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'platform' must be of type 'string', but here has type 'Platform'.

node_modules/@types/node/index.d.ts(580,26): error TS2300: Duplicate identifier 'Buffer'.

node_modules/@types/node/index.d.ts(580,50): error TS2300: Duplicate identifier 'SlowBuffer'.

node_modules/@types/node/index.d.ts(604,22): error TS2415: Class 'EventEmitter' incorrectly extends base class 'internal'. Types of property 'eventNames' are incompatible. Type '() => (string | symbol)[]' is not assignable to type '() => string[]'. Type '(string | symbol)[]' is not assignable to type 'string[]'.

node_modules/@types/node/index.d.ts(624,5): error TS2309: An export assignment cannot be used in a module with other exported elements.

node_modules/@types/node/index.d.ts(769,18): error TS2300: Duplicate identifier 'Agent'.

node_modules/@types/node/index.d.ts(824,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'addressType' must be of type 'string', but here has type 'number | "udp4" | "udp6"'.

node_modules/@types/node/index.d.ts(827,18): error TS2300: Duplicate identifier 'Worker'.

node_modules/@types/node/index.d.ts(1510,17): error TS2300: Duplicate identifier 'CompleterResult'.

node_modules/@types/node/index.d.ts(1547,18): error TS2300: Duplicate identifier 'Script'.

node_modules/@types/node/index.d.ts(2911,18): error TS2300: Duplicate identifier 'TLSSocket'.

node_modules/@types/node/index.d.ts(3108,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'pfx' must be of type 'any', but here has type 'string | Buffer[]'.

node_modules/@types/node/index.d.ts(3109,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'key' must be of type 'any', but here has type 'string | any[] | string[] | Buffer'.

node_modules/@types/node/index.d.ts(3111,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'cert' must be of type 'any', but here has type 'string | string[] | Buffer | Buffer[]'.

node_modules/@types/node/index.d.ts(3112,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'ca' must be of type 'any', but here has type 'string | string[] | Buffer | Buffer[]'.

node_modules/@types/node/index.d.ts(3113,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'crl' must be of type 'any', but here has type 'string | string[]'.

node_modules/@types/node/index.d.ts(3115,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'honorCipherOrder' must be of type 'any', but here has type 'boolean'.

node_modules/@types/node/index.d.ts(3118,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'NPNProtocols' must be of type 'any', but here has type 'string[] | Buffer'.

node_modules/@types/node/index.d.ts(3135,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'key' must be of type 'string | Buffer', but here has type 'string | string[] | Buffer | Buffer[]'.

node_modules/@types/node/index.d.ts(3137,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'cert' must be of type 'string | Buffer', but here has type 'string | string[] | Buffer | Buffer[]'.

node_modules/@types/node/index.d.ts(3138,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'ca' must be of type '(string | Buffer)[]', but here has type 'string | Buffer | (string | Buffer)[]'.

node_modules/@types/node/index.d.ts(3377,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'padding' must be of type 'any', but here has type 'number'.

node_modules/@types/node/index.d.ts(3382,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'padding' must be of type 'any', but here has type 'number'.

node_modules/@types/node/index.d.ts(3429,22): error TS2420: Class 'Readable' incorrectly implements interface 'ReadableStream'. Types of property 'pause' are incompatible. Type '() => Readable' is not assignable to type '{ (): ReadableStream; (): ReadableStream; }'. Type 'Readable' is not assignable to type 'ReadableStream'. Types of property 'eventNames' are incompatible. Type '() => (string | symbol)[]' is not assignable to type '() => string[]'. Type '(string | symbol)[]' is not assignable to type 'string[]'. node_modules/@types/node/index.d.ts(3512,22): error TS2420: Class 'Writable' incorrectly implements interface 'WritableStream'. Types of property 'eventNames' are incompatible. Type '() => (string | symbol)[]' is not assignable to type '() => string[]'. Type '(string | symbol)[]' is not assignable to type 'string[]'. node_modules/@types/node/index.d.ts(3622,5): error TS2309: An export assignment cannot be used in a module with other exported elements.

node_modules/@types/node/index.d.ts(3705,5): error TS2300: Duplicate identifier 'export='.

node_modules/@types/node/index.d.ts(3727,18): error TS2300: Duplicate identifier 'Domain'.

node_modules/@types/node/index.d.ts(3727,18): error TS2420: Class 'Domain' incorrectly implements interface 'NodeJS.Domain'.

Types of property 'eventNames' are incompatible. Type '() => (string | symbol)[]' is not assignable to type '() => string[]'. Type '(string | symbol)[]' is not assignable to type 'string[]'.

node_modules/@types/node/index.d.ts(4019,5): error TS2300: Duplicate identifier 'export='.

typings/globals/node/index.d.ts(78,6): error TS2300: Duplicate identifier 'BufferEncoding'.

typings/globals/node/index.d.ts(234,18): error TS2300: Duplicate identifier 'EventEmitter'.

typings/globals/node/index.d.ts(516,9): error TS2502: 'BuffType' is referenced directly or indirectly in its own type annotation.

typings/globals/node/index.d.ts(517,9): error TS2502: 'SlowBuffType' is referenced directly or indirectly in its own type annotation.

typings/globals/node/index.d.ts(518,26): error TS2300: Duplicate identifier 'Buffer'.

typings/globals/node/index.d.ts(518,50): error TS2300: Duplicate identifier 'SlowBuffer'.

typings/globals/node/index.d.ts(580,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'.

Named property 'addListener' of types 'EventEmitter' and 'Server' are not identical.

typings/globals/node/index.d.ts(580,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'.

Named property 'emit' of types 'EventEmitter' and 'Server' are not identical.

typings/globals/node/index.d.ts(580,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'.

Named property 'on' of types 'EventEmitter' and 'Server' are not identical.

typings/globals/node/index.d.ts(580,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'.

Named property 'once' of types 'EventEmitter' and 'Server' are not identical.

typings/globals/node/index.d.ts(580,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'.

Named property 'prependListener' of types 'EventEmitter' and 'Server' are not identical.

typings/globals/node/index.d.ts(580,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'.

Named property 'prependOnceListener' of types 'EventEmitter' and 'Server' are not identical.

typings/globals/node/index.d.ts(580,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'EventEmitter' and 'Server'.

Named property 'removeListener' of types 'EventEmitter' and 'Server' are not identical.

typings/globals/node/index.d.ts(591,22): error TS2320: Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'addListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(591,22): error TS2320: Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'emit' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(591,22): error TS2320: Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'on' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(591,22): error TS2320: Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'once' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(591,22): error TS2320: Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'prependListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(591,22): error TS2320: Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'prependOnceListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(591,22): error TS2320: Interface 'ServerResponse' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'removeListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(621,22): error TS2320: Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'addListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(621,22): error TS2320: Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'emit' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(621,22): error TS2320: Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'on' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(621,22): error TS2320: Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'once' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(621,22): error TS2320: Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'prependListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(621,22): error TS2320: Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'prependOnceListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(621,22): error TS2320: Interface 'ClientRequest' cannot simultaneously extend types 'EventEmitter' and 'Writable'.

Named property 'removeListener' of types 'EventEmitter' and 'Writable' are not identical.

typings/globals/node/index.d.ts(647,22): error TS2320: Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'.

Named property 'addListener' of types 'EventEmitter' and 'Readable' are not identical.

typings/globals/node/index.d.ts(647,22): error TS2320: Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'.

Named property 'emit' of types 'EventEmitter' and 'Readable' are not identical.

typings/globals/node/index.d.ts(647,22): error TS2320: Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'.

Named property 'on' of types 'EventEmitter' and 'Readable' are not identical.

typings/globals/node/index.d.ts(647,22): error TS2320: Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'.

Named property 'once' of types 'EventEmitter' and 'Readable' are not identical.

typings/globals/node/index.d.ts(647,22): error TS2320: Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'.

Named property 'prependListener' of types 'EventEmitter' and 'Readable' are not identical.

typings/globals/node/index.d.ts(647,22): error TS2320: Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'.

Named property 'prependOnceListener' of types 'EventEmitter' and 'Readable' are not identical.

typings/globals/node/index.d.ts(647,22): error TS2320: Interface 'IncomingMessage' cannot simultaneously extend types 'EventEmitter' and 'Readable'.

Named property 'removeListener' of types 'EventEmitter' and 'Readable' are not identical.

typings/globals/node/index.d.ts(698,18): error TS2300: Duplicate identifier 'Agent'.

typings/globals/node/index.d.ts(743,18): error TS2300: Duplicate identifier 'Worker'.

typings/globals/node/index.d.ts(1004,22): error TS2300: Duplicate identifier 'CompleterResult'.

typings/globals/node/index.d.ts(1044,18): error TS2300: Duplicate identifier 'Script'.

typings/globals/node/index.d.ts(1323,22): error TS2320: Interface 'Server' cannot simultaneously extend types 'Socket' and 'EventEmitter'.

Named property 'removeListener' of types 'Socket' and 'EventEmitter' are not identical.

typings/globals/node/index.d.ts(1886,18): error TS2300: Duplicate identifier 'TLSSocket'.

typings/globals/node/index.d.ts(2188,18): error TS2420: Class 'Readable' incorrectly implements interface 'ReadableStream'.

Types of property 'pause' are incompatible. Type '() => Readable' is not assignable to type '{ (): ReadableStream; (): ReadableStream; }'. Type 'Readable' is not assignable to type 'ReadableStream'. Property 'isPaused' is missing in type 'Readable'. typings/globals/node/index.d.ts(2211,18): error TS2420: Class 'Writable' incorrectly implements interface 'WritableStream'.

Types of property 'eventNames' are incompatible. Type '() => (string | symbol)[]' is not assignable to type '() => string[]'. Type '(string | symbol)[]' is not assignable to type 'string[]'. Type 'string | symbol' is not assignable to type 'string'. Type 'symbol' is not assignable to type 'string'. typings/globals/node/index.d.ts(2229,18): error TS2420: Class 'Duplex' incorrectly implements interface 'ReadWriteStream'.

Types of property 'pause' are incompatible. Type '() => Duplex' is not assignable to type '{ (): ReadWriteStream; (): ReadWriteStream; }'. Type 'Duplex' is not assignable to type 'ReadWriteStream'. Property 'isPaused' is missing in type 'Duplex'. typings/globals/node/index.d.ts(2250,18): error TS2420: Class 'Transform' incorrectly implements interface 'ReadWriteStream'.

Types of property 'pause' are incompatible. Type '() => Transform' is not assignable to type '{ (): ReadWriteStream; (): ReadWriteStream; }'. Type 'Transform' is not assignable to type 'ReadWriteStream'. Property 'isPaused' is missing in type 'Transform'. typings/globals/node/index.d.ts(2343,5): error TS2300: Duplicate identifier 'export='.

typings/globals/node/index.d.ts(2365,18): error TS2300: Duplicate identifier 'Domain'.

typings/globals/node/index.d.ts(2365,18): error TS2420: Class 'Domain' incorrectly implements interface 'NodeJS.Domain'.

Types of property 'eventNames' are incompatible. Type '() => (string | symbol)[]' is not assignable to type '() => string[]'. Type '(string | symbol)[]' is not assignable to type 'string[]'. typings/globals/node/index.d.ts(2625,5): error TS2300: Duplicate identifier 'export='.

`

Technohacker
  • 735
  • 5
  • 19
David
  • 5,403
  • 15
  • 42
  • 72

2 Answers2

1

Uninstall typings. Typescript types are now managed by npm under the @types namespace:

npm uninstall --save typings

Also, delete the typings subdirectory.

Technohacker
  • 735
  • 5
  • 19
1

To update from Angular 2 to Angular 4 please follow this steps:

1 - Ensure you don't use extends OnInit, or use extends with any lifecycle event. Instead use implements <lifecycle event>.

2 - Update all of your dependencies to version 4 and the latest TypeScript using

Mac/Linux

npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@4.0.0 typescript@latest --save

Windows

 npm install @angular/common@next @angular/compiler@next @angular/compiler-cli@next @angular/core@next @angular/forms@next @angular/http@next @angular/platform-browser@next @angular/platform-browser-dynamic@next @angular/platform-server@next @angular/router@next @angular/animations@next --save

3 - If you use animations in your application, you should import BrowserAnimationsModule from @angular/platform-browser/animations in your App NgModule.

4 - Rename your template tags to ng-template.

5 - If you want to validate your forms add ngNativeValidate because angular 4 added novalidate attribute to all forms


if you still having some issues try to update nodejs and Typescript npm install -g typescript@latest

If none of that helped please update your Angular CLI to the latest version

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest

and generate a new Angular 4 project using ng new newProject and move your logic and templates to the new app.

halfer
  • 19,824
  • 17
  • 99
  • 186
Hamed Baatour
  • 6,664
  • 3
  • 35
  • 47