How to install global NPM packages locally

npm install -g serverless
npm install -g terraform
npm install -g mocha
in many cases you only need them for 1-2 projects.
In some cases, you might not have permissions to install packages globally.
The reality is, you don't need to install them globally at all!
Installing a global NPM package locally
Let's take Serverless as an example. Let's say we want to deploy an existing project, but we don't have Serverless installed on our system.First we install the package locally:
npm install serverless
So from the main project directory, we simply run:
./node_modules/.bin/serverless deploy -v
ln -s node_modules/.bin/serverless serverless
./serverless deploy -v
So far I've been using locally installed packages for Serverless, SailsJS, Mocha, Terraform, and a few others as well.
On the next post, we'll try playing around with Serverless and S3, stay tuned!
Posted in
Technology