Security, Tech & Programming
Nodejs CheatSheet

Nodejs CheatSheet

Update all dependencies in package.json

npm i -g npm-check-updates && ncu -u && npm i
npm update
npm install

[!] CocoaPods could not find compatible versions for pod “Firebase/CoreOnly”:

Delete ios/Podfile.lock and then run (in ios folder):

pod install

How to read .env file in nodejs

We need to install the dotenv package using:

npm install dotenv

And then on top of the root file (main.js or index.js) call that module like this:

// based on require | import
// or
import 'dotenv/config'

// then access the values like this:

Difference between require and import

Require is pre-es6 method, while import is new. More differences:

listen EACCES: permission denied

Ports below 1024 are considered priviledged ports and only admin user can open them. Either run your app as a priviledged user or else change the port to more than 1024.

To run as admin / sudo:

sudo node app.js
// or
sudo npm start

Leave a Reply

Your email address will not be published. Required fields are marked *

Hire Me!