Cannot call a namespace ('moment')
See original GitHub issueMy library uses moment import * as moment from 'moment'
.
When I run gulp compile
I hit this error.
Error: Cannot call a namespace ('moment') at error (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:185:14) at Module.error (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:8170:3) at CallExpression.bind (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:6324:17) at eachChild.child (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:5674:34) at keys.forEach.key (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:5685:5) at Array.forEach (native) at ConditionalExpression.eachChild (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:5678:13) at ConditionalExpression.bind (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:5674:8) at eachChild.child (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:5674:34) at keys.forEach.key (C:\SourceCodeNew\IndConsoleSvcProxy\node_modules\rollup\dist\rollup.js:5685:5)
This SO post suggesting change the import to import moment from 'moment'
but it doesn’t work for me because I hit another error Module '"C:/SourceCodeNew/IndConsoleSvcProxy/node_modules/moment/moment"' has no default export.
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (1 by maintainers)
Top GitHub Comments
My workarround:
😃
FWIW, I ran into a similar problem, and solved it by adding
to my
tsconfig.json
. That lets you justimport library from "library"
from CommonJS libraries, instead ofimport * as library from 'library'
, and seems to be a little more forgiving to libraries that otherwise give Typescript trouble