Angular build results in Error: Cannot call a namespace ('v1')?

戏子无情 提交于 2020-01-16 14:20:21

问题


I'm trying this import in an Angular 9 library:

import * as v1 from "uuid/v1";

And VS Code does not draw any errors with this, however when I try to build the library I get this error:

Error: Cannot call a namespace ('v1')

Also this used to work:

import v1 from "uuid/v1";

However when doing that I get the error:

This module is declared with using ‘export =’, and can only be used with a default import when using the ‘allowSyntheticDefaultImports’ flag.

Thoughts?

Update

I tried this within the workspace tsconfig.json file:

  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
   ...

And went back to:

import v1 from "uuid/v1";

And that works. Just curious whether this is the recommended approach ... WRT Treeshaking etc.

Update 2

Turns out that will not work because now I get these errors:

  ● should constructor initialize the store

    TypeError: v1_1.default is not a function

      72 |  */
      73 | export function GUID() {
    > 74 |   return v1();
         |            ^
      75 | }

If I go back to

import * as v1 from "uuid/v1";

And VS Code does not draw any errors with this, however when I try to build the library I get this error:

Error: Cannot call a namespace ('v1')

Then the tests run fine, but I get the same error:

Error: Cannot call a namespace ('v1')

Angular Bug Report

https://github.com/angular/angular-cli/issues/16378

来源:https://stackoverflow.com/questions/59221867/angular-build-results-in-error-cannot-call-a-namespace-v1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!