question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Project fails to compile after adding moment library and its typings to the project

See original GitHub issue

I have done the following list of commands using the angular-cli@0.0.24 on windows and linux. The last ng serve command throws the “Cannot find namespace ‘moment’” error.

ng new ng2cli-moment
cd ng2cli-moment/
ng serve
npm i moment --save
ng serve
typings install moment --ambient --save
ng serve

Livereload server on http://localhost:49152
Serving on http://localhost:4200/
[DiffingTSCompiler]: Typescript found the following errors:
  c:/Users/kovax/workspace/ng2cli-moment/typings/browser/ambient/moment/moment.d.ts (9, 21): Cannot find namespace 'moment'.
Error: [DiffingTSCompiler]: Typescript found the following errors:
  c:/Users/kovax/workspace/ng2cli-moment/typings/browser/ambient/moment/moment.d.ts (9, 21): Cannot find namespace 'moment'.
    at DiffingTSCompiler.doFullBuild (c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:202:29)
    at DiffingTSCompiler.rebuild (c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:101:18)
    at DiffingPluginWrapper.rebuild (c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\lib\broccoli\diffing-broccoli-plugin.js:87:45)
    at c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\node_modules\angular-cli\node_modules\broccoli\lib\api_compat.js:42:21
    at lib$rsvp$$internal$$tryCatch (c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
    at c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:331:11
    at lib$rsvp$asap$$flush (c:\Users\kovax\workspace\ng2cli-moment\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)
    at nextTickCallbackWith0Args (node.js:433:9)
    at process._tickCallback (node.js:362:13)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
martinsvbcommented, Jun 23, 2016

Hello, --ambient was changed to --global parameter

0reactions
angular-automatic-lock-bot[bot]commented, Sep 5, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Importing moment into TypeScript project - Stack Overflow
I am trying to use moment in my TypeScript project but when I use the line, import moment from 'moment'; I get the...
Read more >
How to Add TypeScript to a JavaScript Project - freeCodeCamp
At first it can be used just as JS with .ts files and weird import lines. In this strategy, we will be compiling...
Read more >
How to Use JavaScript Libraries in Angular Project
Using a JavaScript library inside an Angular project is not as straightforward as using it in Angular JS or a plain JavaScript project....
Read more >
A Complete Guide to Using TypeScript in Node.js - Better Stack
We need to set up a configuration file ( tsconfig.json ) for our project before we can start compiling our source files. If...
Read more >
Module not found: Can't resolve 'moment' error | bobbyhadz
To solve the error "Module not found: Error: Can't resolve 'moment'", make sure to install the moment package by opening your terminal in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found