NPM & Frontend Assets
Simple Invoices uses npm (Node Package Manager) to manage frontend vendor libraries: CSS frameworks, JavaScript components, icons, and fonts. This replaces the previous approach of loading these assets from external CDNs (jsDelivr, Google Fonts).
What npm manages
What npm does
npm install: readspackage.json, downloads all libraries intonode_modules/, and generatespackage-lock.jsonwhich locks exact versions for reproducible buildsnpm run copy-assets: runsscripts/copy-assets.js, a custom script that copies only the needed distribution files fromnode_modules/intotemplates/default/vendor/. The app's HTML templates reference these local files instead of CDN URLs
When to run npm
During initial setup
This is required once when you first clone or download the project. It creates node_modules/ and populates templates/default/vendor/.
After pulling code changes
Run npm install if you see package.json was modified in the pull. It will only install new or updated packages.
After editing package.json
If you manually bump a version in package.json:
To update all libraries
This updates all packages to the latest versions within their semver ranges specified in package.json.
To update a single library
Or specify an exact version:
When switching branches
With Docker vs Without Docker
Without Docker (manual / LAMP stack)
You need Node.js installed on your development machine or server. Run:
The templates/default/vendor/ directory is gitignored and built on deploy. It must be regenerated whenever package.json changes.
With Docker
Node.js is not required on your host machine. The Dockerfile includes a multi-stage build:
This means:
- You don't need Node.js installed to build or run the Docker image
- You don't need to run
npm installmanually:docker compose buildhandles it - The final Docker image contains no Node.js: only the copied asset files
- When
package.jsonchanges, rebuild the image:
Comparison
Files involved
Troubleshooting
"Command not found: npm"
Node.js is not installed. Install it from nodejs.org or use Docker instead.
"Cannot find module" or missing assets
Run npm install: the node_modules/ directory may be missing or outdated.
Assets load but look wrong (old styles)
Run npm run copy-assets: the vendor directory may have stale files.
Docker build fails at npm stage
Clear Docker's build cache: