Errors with ml5.js code (from prior to 1.0 release)!
Opened this issue ยท 0 comments
๐ Hello, ml5.js community!
We noticed that many people have experienced issues with the library recently, seeing errors such as ... is not a function
. ๐ข This is most likely due to code that was written for the library prior to the recent 1.0 release. The following should help you resolve any errors! ๐ซ ๐
Quick Fix!
In the ml5 library's script tag, change latest
to 0.12.2
. If you are using p5.js, you can find the script tag in the index.html
file of your p5 sketch.
Change this:
<script src="https://unpkg.com/ml5@latest/dist/ml5.min.js"></script>
to this:
<script src="https://unpkg.com/ml5@0.12.2/dist/ml5.min.js"></script>
Hope this works! ๐ค
Why are there errors?
We recently released a new version of the library, updating from version 0.12.2 to 1.0.1 (yay!!!). The library was re-designed be even friendlier, and included several breaking changes. Some functions from the previous version (0.12.2) no longer exist in 1.0.1. For example, poseNet.on("pose", gotPose)
has been removed and changed to bodyPose.detectStart(video, gotPose)
.
The ml5@latest
tag automatically uses the latest version of the library, which is version 1.0.1. If you are on version 1.0.1 and attempt to call a function that has been removed, you will likely see the ... is not a function
error. By specifying ml5@0.12.2
in the script tag, you can continue using the previous version of the library and call the now deprecated functions.
Since we have passed the 1.0.0 landmark, we will be following semantic versioning for future releases. Going forward, we recommend specifying a major version number in the script tag, such as ml5@1
. Using ml5@latest
might cause issues if and when there are additional breaking changes.
We will still host version** 0.12** of the library, however, it will no longer receive feature updates. We recommend giving the new library a try! The new reference document is a great place to start as well as a collection of example sketches showcasing the models and functions!