Due to permission restrictions and the need for your NPM credentials, you'll need to publish from your local machine.
Download all the files from this workspace to your local machine.
Open terminal in the project folder and run:
npm installnpm run buildThis creates the dist/ folder with all necessary files.
# Create a test package
npm pack
# This creates ninth-js-1.0.0.tgz
# You can test install it with:
npm install ./ninth-js-1.0.0.tgznpm loginEnter your credentials:
- Username: digitalcloud.no
- Password: [your password]
- Email: [your email]
Verify login:
npm whoami
# Should display: digitalcloud.nonpm publishThat's it! Your package will be live on NPM.
# Check package info
npm view ninth-js
# Try installing it
npm install ninth-jsBased on your package.json configuration, NPM will publish:
dist/folder (all build outputs)README.mdLICENSEpackage.json
Everything else (source files, tests, etc.) is excluded via .npmignore.
Your package will be available at:
- NPM: https://www.npmjs.com/package/ninth-js
- Unpkg CDN: https://unpkg.com/ninth-js@latest/dist/ninth-js.umd.js
- JSDelivr CDN: https://cdn.jsdelivr.net/npm/ninth-js@latest/dist/ninth-js.umd.js
If "ninth-js" is already taken, you have two options:
Option 1: Use a Scoped Package
Update package.json:
{
"name": "@digitalcloud.no/ninth-js"
}Then publish with:
npm publish --access publicOption 2: Choose a Different Name
Update package.json:
{
"name": "ninth-graphics"
}Ensure all dev dependencies are installed:
npm install --save-dev rollup @rollup/plugin-node-resolve @rollup/plugin-commonjs @rollup/plugin-terserMake sure you're using the correct credentials and your account is verified.
If you get EACCES errors:
# On Mac/Linux
sudo npm publish
# Or fix permissions
sudo chown -R $USER /usr/local/lib/node_modulesWhen you need to publish updates:
# Update version
npm version patch # 1.0.0 → 1.0.1
npm version minor # 1.0.0 → 1.1.0
npm version major # 1.0.0 → 2.0.0
# Rebuild and publish
npm run build
npm publishAfter publishing, you can track:
- Downloads at: https://www.npmjs.com/package/ninth-js
- Package health
- Version history
- Dependent packages
Your library will be globally available to all developers!