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.

Plugin import in angular project throws error 'no default export'

See original GitHub issue

Describe the bug Plugin import throws error in angular project / browser dayjs__WEBPACK_IMPORTED_MODULE_5__(...).month(...).startOf(...).weekday is not a function

Expected behavior I can use most dayjs functions just fine with import * as dayjs from 'dayjs'.

But when I need to use plugins, I import with import * as weekday from 'dayjs/plugin/weekday, it throws me this error in the browser - even though the compiler recognises the function weekday just fine:

dayjs__WEBPACK_IMPORTED_MODULE_5__(...).month(...).startOf(...).weekday is not a function

image

Trying to import the weekday plugin with import weekday from 'dayjs/plugin/weekday'; throws compiler error Module '"C:/.../node_modules/dayjs/plugin/weekday"' has no default export.

OR import { weekday } from 'dayjs/plugin/weekday'; throws compiler error Module '"C:/.../node_modules/dayjs/plugin/weekday"' has no exported member

Information

  • Day.js Version 1.8.14
  • OS: Win 10 / Angular Typescript Project
  • Browser Chrome 74

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
thomascsdcommented, Jun 14, 2019

Use dayjs.extend, see doc

import * as dayjs from 'dayjs';
import * as weekday from 'dayjs/plugin/weekday';
dayjs.extend(weekday);
0reactions
iamkuncommented, Jan 3, 2021

I’ll close this issue since it’s been a while since it’s been opened. Feel free to reopen if you have updates on this

Read more comments on GitHub >

github_iconTop Results From Across the Web

error TS1192: Module '" A.module"' has no default export
This was a simple error. It occurred due to the missing {} around the module name in the import statement itself.
Read more >
Module has no default export Error in TypeScript | bobbyhadz
The "Module has no default export" error occurs when we try to import as default from a module that doesn't have a default...
Read more >
@rollup/plugin-commonjs - npm
Controls what is the default export when importing a CommonJS file from an ES module. true : The value of the default export...
Read more >
Documentation - Modules - TypeScript
Each module can optionally export a default export. Default exports are marked with the keyword default ; and there can only be one...
Read more >
can't import the named export from default-exporting module ...
You need to import { REACTIVE_FORM_DIRECTIVES } from '@angular/forms' in your controller and add it to directives in @Component . That will fix...
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