App compile error: Cannot find namespace 'moment'

I’ve been working on my angular 2 app yesterday and everything ran fine.
Today I was trying to npm start my app and I get this compile error:

typings/browser/ambient/moment/index.d.ts(9,21): error TS2503: Cannot find namespace 'moment'.

Although I didn’t mention anything releaeted to moment in my app!

What can cause this error if I’m not using anything releated to moment?

I tried:

  1. The solutions here
  2. npm remove moment

Any ideas?

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

I had the same problem. Just fixed it.

When you run:

typings install moment --ambient --save

You’ll likely see an info message like this:

typings INFO reference Stripped reference “https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/moment/moment-node.d.ts” during installation from “moment”

This was my clue that I also needed to install the typings for moment-node and then everything worked.

typings install moment-node --ambient --save

Good luck!