Project fails to compile after adding moment library and its typings to the project
See original GitHub issueI 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:
- Created 8 years ago
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello, --ambient was changed to --global parameter
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.