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.
CommonJS
is the original module system (require
,module.exports
and.cjs
files).ECMAScript
module system became a standard and support was added for it (import
,export
and.mjs
files).- JavaScript
.js
files are treated as whatever the module system for the project is, defined inpackage.json
, CommonJS by default or ECMAScript ("type": "module"
).
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
- By default saves the package to
dependencies
. --save-dev
saves the package todevDependencies
.
Move a package from dev
to prod
or viceversa.
npm install <package> --save-dev
npm install <package> --save-prod
Uninstall a package.
npm uninstall <package>
Install a global package.
npm install --global <package>
npm install --global <package>@<version>
Uninstall a global package.
- Run
npm list --global
. - Go to
C:\Users\<user>\AppData\Roaming\npm
. - Delete the package files.
- Go to
node_modules
and delete the 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
npm update <package>
npm update <package> --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 |
Bowser | npm install bowser |
dnd | npm install @hello-pangea/dnd |
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 |
esbuild | npm install --save-exact --save-dev esbuild |
fs-extra | npm install fs-extra |
ics | npm install ics |
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 --save-dev @types/multer |
Nest | npm install --global @nestjs/cli |
Nest Schedule | npm install @nestjs/schedule npm install --save-dev @types/cron |
Nest Serve Static | npm install @nestjs/serve-static |
Nodemailer | npm install nodemailer npm install --save-dev @types/nodemailer |
node-qrcode | npm install qrcode npm install --save-dev @types/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 --save-dev @types/react npm install --save-dev @types/react-dom |
React Hot Toast | npm install react-hot-toast |
React Transition Group | npm install react-transition-group npm install --save-dev @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 npm install --save-dev @types/three |
TypeORM | npm install typeorm npm install @nestjs/typeorm |
Typescript | npm install typescript npm install --save-dev typescript |
uuid | npm install uuid |
Vite | npm install vite npm install @vitejs/plugin-react |
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.
- Providers (classes with
@Injectable()
) are added to theexports
array of the producer module. - Modules (classes with
@Module()
) are added to theimports
array of a consumer module. - Dynamic modules (classes that use
register
orforRoot
) should always export the module instead of its services (the module has a configuration necessary for the services to work).
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