To add a package or module from NPM, your project must have a package.json file. By default the following Glitch starter templates include a package.json:
Now, here's how to add an NPM package to your Glitch project:
- Open the project in the editor.
- In the file view on the left, click on package.json.
- Click the + ADD PACKAGE button which can be found at the top of the package.json view.
- Use the search box to find the NPM package that you would like to add to your project.
- When you find the package that you would like to add, click on it and the project editor will automatically refresh, adding the package selected to your package.json file.
Here's how to update a package that has already been installed:
- When there is an update available for a package that is already being used, an alert will appear next to the + ADD PACKAGE button.
- Click the button to review the available updates.
- Click on the update that you would like to install.
When adding packages/modules to your Glitch project, remember the following:
- On Glitch, NPM packages don't count towards the project disk space limit shown in the project editor App Status tray.
- There's a separate 1GB limit for NPM packages and currently, the editor does not provide a status meter to show you how much of this space is being used.
- For this reason, try to avoid installing unnecessary packages to your project. If you exceed the npm package limit, your project may be automatically suspended by our system. If this happens, you can use the instructions here to address the issue.