Do it yourself
#- In the file list, find NPM PACKAGES and choose the plus button next to it.
- Type the package's name in Search by name, like
canvas-confetti, and pick it from the results. - Pick a version. The list shows tags first, like
latest, then every version. - The package appears under NPM PACKAGES with its version, and in
package.jsonunderdependencies. - Import it in your code, like
import confetti from 'canvas-confetti'. The preview loads it on the next run.
You can also start from the import. When your code imports a package that package.json does not have, the preview shows Missing Module with the package and the file that imports it. Pick a version under Select version and choose Install followed by the package's name.
Or edit package.json yourself: the NPM PACKAGES list follows its dependencies.
To remove a package, choose the ... button next to it, then Delete.
If it doesn't work
#"No packages found"
#The search found nothing. Check the spelling of the name.
"This package cannot be installed automatically."
#Playcode could not find the package on npm. Check the name in the import.
The package is installed, but the import fails
#The package is there, but the path after its name does not resolve, like a file inside the package without its ending. Read the error under the preview: it names the path that failed. Fix the import.
The package does not work in the preview
#It may need Node.js, like a web server or file access. Code in a browser project runs in your browser. Use a Cloud app for it: see Browser and Cloud projects.
Limits
#- Only
dependenciescount.devDependenciesand thescriptsinpackage.jsondo not run. - There is no terminal in a browser project. A Cloud app has one: see Use the terminal.
- A Python project shows its own packages list instead of NPM PACKAGES.