1

I'm using Ionic2 and socket.io

When I do ionic serve I get this error in the terminal:

TypeScript error: typings/globals/socket.io/index.d.ts(357,30): Error TS2503: Cannot find namespace 'NodeJS'.
TypeScript error: typings/globals/socket.io/index.d.ts(739,28): Error TS2503: Cannot find namespace 'NodeJS'.

Node version is 4.2.6

My typings.json looks like this:

{
  "dependencies": {},
  "devDependencies": {},
  "globalDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
    "socket.io": "registry:dt/socket.io#1.4.4+20160317120654",
    "socket.io-client": "registry:dt/socket.io-client#1.4.4+20160317120654"
  }
}

If I open typings/globals/socket.io/index.d.ts (with sublimeText) I see this : enter image description here

As you can see also sublimeText complains about NodeJS namespace.

2 Answers 2

2

Had a similar issue with a Node Typescript project. Turns out I just didn't have Node set as a global dependency.

typings install dt~node --global --save-dev

shortcut:

typings i -GD dt~node
Sign up to request clarification or add additional context in comments.

Comments

0

Could you provide your typings.json?

Try to update to the latest commit 7de6c3dd94feaeb21f20054b9f30d5dabc5efabd

I also had same problem (with different namespaces), update fixed it.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/socket.io-client/socket.io-client.d.ts

EDIT: Try:

"socket.io": "github:DefinitelyTyped/DefinitelyTyped/socket.io/socket.io.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
"socket.io-client": "github:DefinitelyTyped/DefinitelyTyped/socket.io-client/socket.io-client.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd"

1 Comment

I tried to update my typings.json file as you suggested but it still doesnt work. I've edited the question, look at the picture I uploaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.