Published: March 10 2024
npm pack for local package dependency testing
Steps to test npm package dependencies locally without publishing to npm.
Installing the packed tarball works exactly like installing a package from an npm repo whereas linking to the local package with npm link doesn't always behave the same as a real repo.
Build and pack local package
The npm pack command generates a tarball (.tgz) of the built project with the name and version from the package.json file (e.g. my-local-package-1.0.0.tgz).
cd ~/Projects/my-local-packagenpm inpm run buildnpm pack
Install local package in web app
cd ~/Projects/my-web-appnpm i ../my-local-package/my-local-package-1.0.0.tgznpm start
Extra step for Next.js apps
Might need to clear the Next.js cache by deleting the .next/cache folder before installing the local package (step 2 above).
rm -rf .next/cache
Need Some NodeJS Help?
Search fiverr for freelance NodeJS developers.
Follow me for updates
When I'm not coding...
Me and Tina are on a motorcycle adventure around Australia.
Come along for the ride!
More NodeJS Posts
- Next.js 13 + MySQL - User Registration and Login Tutorial with Example App
- Next.js 13 Middleware for Authentication and Error Handling on API Routes
- Next.js 13 + MongoDB - User Registration and Login Tutorial with Example App
- Mongoose + MongoDB - Fix for MongoParseError: options usecreateindex, usefindandmodify are not supported
- Next.js 11 + MongoDB - Connect to Mongo database with Mongoose
- React 18 Authentication with Node.js JWT API
- Angular 14 Authentication with Node.js JWT API
- Vue 3 Authentication with Node.js JWT API
- Angular + Node.js - Connect an Angular App to a Node.js API
- Node.js + MS SQL Server - Simple API for Authentication, Registration and User Management
- Node + MSSQL - Auto Create/Update SQL Server Database with Sequelize and Tedious
- Node.js + MySQL - Connect to MySQL database with Sequelize & MySQL2
- Node.js + MSSQL - Connect to SQL Server with Sequelize & Tedious
- Node.js + MS SQL Server - CRUD API Example and Tutorial
- Node.js + MySQL - CRUD API Example and Tutorial
- Node.js - Simple Proxy to Pass Through HTTP Requests to an External URL
- Next.js - Basic HTTP Authentication Tutorial with Example App
- Next.js API - Global Error Handler Example & Tutorial
- Next.js API - Add Middleware to API Routes Example & Tutorial
- Next.js 11 - User Registration and Login Tutorial with Example App
- Next.js 11 - JWT Authentication Tutorial with Example App
- Next.js 10 - CRUD Example with React Hook Form
- Sequelize + MySQL - Create database if it doesn't exist
- Node.js + MySQL - Boilerplate API with Email Sign Up, Verification, Authentication & Forgot Password
- Node.js + MySQL - Simple API for Authentication, Registration and User Management
- Node.js + Express API - Request Schema Validation with Joi
- Node.js - Send Emails via SMTP with Nodemailer
- Node.js - Hash and Verify Passwords with Bcrypt
- Node.js + MongoDB API - JWT Authentication with Refresh Tokens
- Node + Mongo - Boilerplate API with Email Sign Up, Verification, Authentication & Forgot Password
- Vue.js + Node.js on AWS - How to Deploy a MEVN Stack App to Amazon EC2
- Angular + Node.js on AWS - How to Deploy a MEAN Stack App to Amazon EC2
- React + Node.js on AWS - How to Deploy a MERN Stack App to Amazon EC2
- Vue.js + Node - Server Side Pagination Tutorial & Example
- React + Node - Server Side Pagination Tutorial & Example
- Angular 8 + Node - Server Side Pagination Tutorial & Example
- Deploy to Heroku - Node + Mongo API for Authentication, Registration and User Management
- Node.js - Role Based Authorization Tutorial with Example API
- Setup Node.js + MongoDB Production Server on Ubuntu 18.04 - Ubuntu 19.04
- NodeJS - Basic Authentication Tutorial with Example API
- Node.js + Express 4 - JWT Authentication Tutorial with Example API
- NodeJS + MongoDB - Simple API for Authentication, Registration and User Management
- Node - Get Public Key From Private Key with JavaScript
- Angular 2 - Refresh Without 404 in Node & IIS
- MEAN with Angular 2/5 - User Registration and Login Example & Tutorial
- MEANie - Lightweight MEAN Stack CMS & Blogging Platform
- AngularJS - Enable HTML5 Mode Page Refresh Without 404 Errors in NodeJS and IIS
- NodeJS - Setup a Simple HTTP Server / Local Web Server
- Getting Foreman working on Windows 7 after installing the Heroku Toolbelt