You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
__WEBPACK_IMPORTED_MODULE_4_moment__ is not a function when trying to use moment.js with typings #1974
OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Ubuntu 14.04
Versions. Please run ng --version. If there's nothing outputted, please run
in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.3.1
os: linux x64
Repro steps. Was this an app that wasn't created using the CLI? What change did you
do on your code? etc.
This is a project done from the start with angular cli.
Install moment:
npm install moment --save
typings install dt~moment --global --save
Include in ts file: import * as moment from 'moment'
and call any method: moment().calendar()
The log given by the failure. Normally this include a stack trace and some
more information.
If I leave import * as moment from 'moment' in the component, the component wont run at all. If I remove it, the component works properly but I get client?93b6:49 [default] /home/alejo/projects/ng-backend/src/app/services/offers/offers.service.ts:37:31 Cannot find name 'moment'. when serving the app.
@alejoar I tested it again on a clean project, and for me it works.
Did you start your project with angular-cli before the webpack version? Did you follow the upgrade manual?
FYI, this is how I created my project:
install/update angular-cli + create new project:
npm install -g angular-cli@webpack
ng new moment-test
in the new project, I installed moment:
cd moment-test
npm install --save moment
npm install --save-dev @types/moment
finally I adapted app.compoment.ts to use moment:
import { Component } from '@angular/core';
import * as moment from 'moment';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!' + moment().format();
}
finally, running ng serve and opening localhost:4200 and everything works fine.
With moment in scripts I got __WEBPACK_IMPORTED_MODULE_4_moment__ is not a function. Without moment in scripts, fullcalendar does not work but moment works in *.ts file with import * as moment from 'moment';
No this command is not working guys,
Please let me know what is the
TypeError: __WEBPACK_IMPORTED_MODULE_2_react_apollo___default(...) is not a function
While, this error occurs after the npm start.
I had tried with so many commands which had shared with this github issues....
Then, I had rectify with the commands.
Thanks in advance....
Activity
rodikal commentedon Sep 6, 2016
the webpack version doesn't use typings anymore, see the 3rd party library installation section of the README file:
alejoar commentedon Sep 7, 2016
@rodikal thank you, but that didn't work.
After doing
I still get the exact same error as before. What could I be doing wrong?
rodikal commentedon Sep 8, 2016
@alejoar I tested it again on a clean project, and for me it works.
Did you start your project with angular-cli before the webpack version? Did you follow the upgrade manual?
FYI, this is how I created my project:
install/update angular-cli + create new project:
in the new project, I installed moment:
finally I adapted
app.compoment.tsto use moment:finally, running
ng serveand openinglocalhost:4200and everything works fine.I've uploaded the project here: https://github.com/rodikal/moment-test
MrChoclate commentedon Sep 14, 2016
I got the same error.
I also need to have moment as a global dependency for fullcalendar so I did:
With moment in scripts I got
__WEBPACK_IMPORTED_MODULE_4_moment__ is not a function. Without moment in scripts, fullcalendar does not work but moment works in *.ts file withimport * as moment from 'moment';EDIT:
filipesilva commentedon Sep 21, 2016
Closing in favor of #2141 since it contains more detailed information on what appears to be the real problem.
Sabrinsulthana commentedon Aug 14, 2018
No this command is not working guys,
Please let me know what is the
TypeError: __WEBPACK_IMPORTED_MODULE_2_react_apollo___default(...) is not a function
While, this error occurs after the npm start.
I had tried with so many commands which had shared with this github issues....
Then, I had rectify with the commands.
Thanks in advance....
Vishnu4a7 commentedon May 13, 2019
Hi Folks,
i am facing below error. Can anyone help me on this please. i am using intro.js version version 1.1.1.
ERROR TypeError: intro_js_intro_js__WEBPACK_IMPORTED_MODULE_3___default(...) is not a function
Thanks in advance.
angular-automatic-lock-bot commentedon Sep 9, 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.
fix(@nguniversal/common-engine): ReferenceError: URL is not defined