Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM : Cannot find name 'EmscriptenModule' #3866

Closed
sbstcano opened this issue Aug 31, 2020 · 8 comments
Closed

WASM : Cannot find name 'EmscriptenModule' #3866

sbstcano opened this issue Aug 31, 2020 · 8 comments

Comments

@sbstcano
Copy link

sbstcano commented Aug 31, 2020

Hi,
I can't compile my Angular 9 project because of this error.
I'm using version 2.3.0 of wasm.

ERROR in node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm.d.ts:18:44 - error TS2304: Cannot find name 'EmscriptenModule'.
@rthadur rthadur self-assigned this Aug 31, 2020
@rthadur
Copy link
Contributor

rthadur commented Aug 31, 2020

@sbstcano
Copy link
Author

sbstcano commented Sep 1, 2020

@sbstcano did you install Emscripten from here https://github.com/tensorflow/tfjs/tree/master/tfjs-backend-wasm#emscripten-installation ?

Yes, I tried and it doesn't help

@rthadur
Copy link
Contributor

rthadur commented Sep 1, 2020

@sbstcano did you try with previous version ?

@sbstcano
Copy link
Author

sbstcano commented Sep 1, 2020

@sbstcano did you try with previous version ?

Yes and sadly it doesn't help. I tried with 2.1.0, 2.0.1, 1.7.4. I tried to downgrade my angular version to ^8. I tried ^10. Angular uses es5 and webpack. Can it be related?

@rthadur rthadur removed their assignment Sep 15, 2020
@sivarajakani
Copy link

I also have this issue, you found a way to handle this issue?

@rthadur
Copy link
Contributor

rthadur commented Mar 9, 2021

@jinjingforever gentle ping if you got chance to look in to this issue, thank you

@jinjingforever
Copy link
Collaborator

One way to fix this is to add "@types/emscripten" to the compilerOptions.types field in tsconfig.app.json. Here is what mine looks like:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": [
      "@types/emscripten"
    ]
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ]
}

(if you don't have tsconfig.app.json, just edit the same field in tsconfig.json)

The reason is that: EmscriptenModule is defined in the emscriptem types package in the global namespace. By default, when an angular app is generated, the compilerOptions.types field is set to an empty array, which means the compiler will not automatically add these "globals" to your app.

Another fix would be to remove the empty compilerOptions.types field from tsconfig.json and tsconfig.app.json.

Please give it a try, and let me know any problems. I will also add this to our README file.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants