learn-tfjs icon indicating copy to clipboard operation
learn-tfjs copied to clipboard

Uncaught (in promise) TypeError: forwardFunc is not a function

Open anjanesh opened this issue 3 years ago • 16 comments

Today I did gh repo clone GantMan/learn-tfjs I did npm i at chapter2/web/web-toxicity http://localhost:1234/ shows : Uncaught (in promise) TypeError: forwardFunc is not a function

anjanesh avatar Jun 26 '21 12:06 anjanesh

Take a quick look at this fix, and let me know: https://github.com/tensorflow/tfjs/issues/2329

GantMan avatar Jun 26 '21 15:06 GantMan

I just pulled down this chapter and ran npm i as well. The install went well, and then I did an npm start and it ran the page.

It appears the issue is local. I'll run the project on my laptop later this afternoon to verify.

GantMan avatar Jun 26 '21 15:06 GantMan

But what could the local issue be when the node/node-toxicity runs perfectly ? It's only the web version that running into an issue. Its either typescript or parcel ? I don't have @tensorflow/tfjs-node in /workspace/ML/learn-tfjs/chapter2/web/web-toxicity/package.json.

anjanesh avatar Jun 26 '21 16:06 anjanesh

I did two things to make this work. First was delete the existing package-lock.json and then I changed the dependency for the toxicity model from "@tensorflow-models/toxicity": "^1.2.2" to "@tensorflow-models/toxicity": "1.2.2" (removing the carrot)

hermano360 avatar Aug 15 '21 23:08 hermano360

Thanks so much @hermano360

It looks like they might have made a mistake in semver.

Do either of you want to do a PR for credit?

GantMan avatar Aug 16 '21 14:08 GantMan

I am still out of luck - I am using the simple an pure node examples.

anjanesh avatar Aug 16 '21 15:08 anjanesh

@anjanesh - I ran the code through CodeSandbox.io to assure it would work, and it does

LINK: https://codesandbox.io/s/chapter2-web-toxicity-ty8qj Screenshot:
chapter 2 working

Hopefully that helps.

GantMan avatar Aug 16 '21 23:08 GantMan

@anjanesh do you have a repo with your changes we could take a look at?

@GantMan I'll look to add the PR if that's ok

hermano360 avatar Aug 16 '21 23:08 hermano360

Sounds good @hermano360! Credit where credit is due.

I had hoped that the package-lock.json would have avoided errors like this, but it's obviously better to just modify package.json! Thanks for contributing.

GantMan avatar Aug 16 '21 23:08 GantMan

@anjanesh do you have a repo with your changes we could take a look at? I didn't edit any code - I simply am running the code in GantMan's github repo.

So I tried this on my work laptop - Dell Windows 10 with node. It's all working as expected. So this error is specific to my personal MacBook which is showing forwardFunc is not a function in FireFox, Chrome and Opera.

anjanesh avatar Aug 17 '21 02:08 anjanesh

@anjanesh.

Please see above. You need to delete the package-lock.json file and change the dependency for the toxicity model from "@tensorflow-models/toxicity": "^1.2.2" to "@tensorflow-models/toxicity": "1.2.2" (removing the caret).

hermano360 avatar Aug 17 '21 02:08 hermano360

Yes hermano360 - I did that yesterday and reinstalled the node_modules. Still same error. I think this is specific to my nodeJS version ? v14.17.5

anjanesh avatar Aug 17 '21 02:08 anjanesh

Is it the node folder that is failing? You had originally said it was the web folder. Your NodeJS version won't matter in the web folder. I know it can get a bit confusing.

GantMan avatar Aug 17 '21 15:08 GantMan

learn-tfjs/chapter2/node/node-toxicity works perfectly.

learn-tfjs/chapter2/web/web-toxicity returns the forwardFunc error even after trying various things to fix it including hermano360's method.

So, now I understand - it probably isn't the node issue but the same web code is working flawlessly on my Windows 10 laptop. So I don't get why it isn't on my MacBook Pro on all browsers - so I thought it had something to do with node.

anjanesh avatar Aug 17 '21 15:08 anjanesh

That's definitely strange. The error seems to happen when you have two versions of TFJS that are not compatible in the same repo, so maybe clean the npm cache with npm cache clean and then do a fresh npm i ?

GantMan avatar Aug 17 '21 16:08 GantMan

@anjanesh ~~this is the only thing that's worked for me.~~

I'm running it on my macBook (Big Sur, Apple M1)

Edited for update

I needed to use node v16.7.0 to properly install the packages, otherwise I would error out. And now it's working withimport "@tensorflow/tfjs"; and "@tensorflow-models/toxicity": "^1.2.2"

BekahHW avatar Aug 20 '21 21:08 BekahHW