Node.js Version Causing JSON Parse Errors: A Solution
Unexpected JSON error Happy 2025! Starting the year by sharing a solution that might save you some debugging time.
Posted in TechnologyHow to install global NPM packages locally
Too many NPM libraries are demanding to be globally installed, to name a few:While it's sometimes very useful to have some of these components globally available,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:Then, on our node_modules/ directory, there's a hidden .bin/ directory, where the serverless binary is located.npm install serverless
So from the main project directory, we simply run:Now if you want to make it a bit more snappy, you could add a shortcut (i.e. symbolic link) to the binary:./node_modules/.bin/serverless deploy -v
And from now on simply run any serverless command like so:ln -s node_modules/.bin/serverless serverless
On rare occasions, some packages' binaries are not under node_modules/.bin/ but somewhere inside the package's directory, such as node_modules/serverless/bin/../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 TechnologyBasics of MeanJS
Posted in TechnologyMEAN.JS Installation
Posted in Technology- Previous Page: 1 of 1 Next