learn-tfjs
learn-tfjs copied to clipboard
Uncaught (in promise) TypeError: forwardFunc is not a function
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
Take a quick look at this fix, and let me know: https://github.com/tensorflow/tfjs/issues/2329
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.
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.
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)
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?
I am still out of luck - I am using the simple an pure node examples.
@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:
Hopefully that helps.
@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
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.
@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.
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).
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
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.
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.
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
?
@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"