Cheatsheets

Personal collection of cheatsheets.

Node.js

Node.js is a JavaScript runtime built on V8 JavaScript engine.

Index

Install

A list of available versions can be found in the releases section of the blog.

Ubuntu.

curl -fsSL https://deb.nodesource.com/setup_current.x -o setup_node.sh
chmod +x setup_node.sh
./setup_node.sh
apt-get install -y nodejs

Versions.

https://deb.nodesource.com/setup_current.x
https://deb.nodesource.com/setup_14.x
https://deb.nodesource.com/setup_13.x
https://deb.nodesource.com/setup_12.x
https://deb.nodesource.com/setup_11.x
https://deb.nodesource.com/setup_10.x

Packages

Node Package Manager (npm) is the package manager of Node.

Update npm.

npm install --global npm@latest

Initialize a module directory.

npm init

Run an application.

npm run
npm run <script>
npm run --prefix <path/to/package.json> <script>

Install all packages.

npm install

Install a package.

npm install <package>
npm install <package>@<version>
npm install git+https://<host>/<user>/<package>.git
npm install git+ssh://git@<host>/<user>/<package>.git

Uninstall a package.

npm uninstall <package>

Install a global package.

npm install --global <package>
npm install --global <package>@<version>

Uninstall a global package.

List global packages.

npm list --global

List packages.

npm list --depth=0

Check outdated packages.

npm outdated

Update packages.

npm update
npm update --save

Recreate package-lock.json.

npm install --package-lock-only

Symlink a package folder, handy to work and test a package iteratively without having to continually rebuild.

npm link <package>
npm unlink <package>

Create a tarball from a package.

npm pack

Login to a registry.

npm login --registry=<url> --scope=<user>
npm login --registry=https://npm.pkg.github.com --scope=@adcimon

Publish a package.

npm publish
npm publish <folder>

List of packages.

Package Install
Axios npm install axios
dnd-kit npm install @dnd-kit/core
dotenv npm install dotenv
Electron npm install --save-dev electron
Electron Builder npm install --save-dev electron-builder
fs-extra npm install fs-extra
jsonwebtoken npm install jsonwebtoken
ms npm install ms
Material UI npm install @mui/material @emotion/react @emotion/styled
Material UI Icons npm install @mui/icons-material
Moment npm install moment
Multer npm install multer
npm install @types/multer
Nest npm install --global @nestjs/cli
Nest Schedule npm install @nestjs/schedule
npm install @types/cron
Nest Serve Static npm install @nestjs/serve-static
Nodemailer npm install nodemailer
npm install @types/nodemailer
node-qrcode npm install qrcode
Passport npm install passport
npm install @nestjs/passport
Passport Local npm install passport-local
Passport JWT npm install passport-jwt
npm install @nestjs/jwt
React npm install react
npm install @types/react
npm install @types/react-dom
React Beautiful DnD npm install react-beautiful-dnd
npm install @types/react-beautiful-dnd
React Hot Toast npm install react-hot-toast
React Transition Group npm install react-transition-group
npm install @types/react-transition-group
Recoil npm install recoil
serve npm install --global serve
SQLite npm install sqlite3
Tailwind CSS npm install --save-dev tailwindcss
Three npm install three
TypeORM npm install typeorm
npm install @nestjs/typeorm
Typescript npm install typescript
npm install --save-dev typescript
npm install --global typescript
uuid npm install uuid
ws npm install ws
npm install @nestjs/websockets
npm install @nestjs/platform-ws
Socket.io npm install socket.io
npm install @nestjs/websockets
npm install @nestjs/platform-socket.io
yup npm install yup

Electron

Electron is a free and open-source software framework developed and maintained by GitHub designed to create desktop applications using web technologies which are rendered using a flavor of the Chromium browser engine, and a backend using the Node.js runtime environment.

Install.

mkdir my-app
cd my-app
npm init
npm install --save-dev electron

Build with Electron Builder.

electron-builder --win [nsis|nsis-web|portable]

Startup project.

https://github.com/electron-react-boilerplate/electron-react-boilerplate

Nest.js

Nest.js is a framework for building efficient, scalable web applications.

Nest is built around the design pattern Dependency injection and has a built-in container that resolves relationships between providers using a constructor based dependency injection.

Install CLI.

npm install --global @nestjs/cli

Print version.

nest --version

Create a new project.

nest new myproject

Build the application.

npm run build

Run the application.

npm run start:dev
npm run start:debug
npm run start:prod

Run unit tests.

npm run test:watch

Run integration tests.

npm run test:e2e

Tailwind CSS

Tailwind CSS is a utility-first CSS framework for rapidly building custom user interfaces.

Install.

npm install --save-dev tailwindcss

Create default configuration file tailwind.config.js.

npx tailwindcss init --full

Build CSS.

npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch

Build CSS with all the classes.

module.exports = {
  content: ["./src/**/*.{html,js}"],
  safelist: [
    {
      pattern: /(.*?)/,
    },
  ],
  ...

TypeScript

TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.

Install.

npm install typescript
npm install --save-dev typescript
npm install --global typescript

Check version.

tsc --version

Generate tsconfig.json.

tsc --init

Install base tsconfig.json files.

npm install --save-dev @tsconfig/recommended