NodeJS - goatandsheep/goatandsheep.github.com GitHub Wiki

Introduction

Why

  • Asynchronous
  • Single-threaded

Basically it creates tasks and when it's not busy waiting for response requests and stuff it does other things in the queue.

NPM

Node Package Manager helps the community work together to build components of code to reduce the amount of time needed to get a project running.

Setup

Windows

  1. npm config get prefix
  2. Move result to Environment Variables > Path with a semicolon

Running

  1. Install all the packages in your directory: npm init
  2. Run: node app.js

NPM

  • Install: npm install <package> --save

Circular Dependencies

This isn't always bad but sometimes it causes errors. When errors come up that are caused by circular dependencies, first use eslint-plugin-import library

in your eslint config add:

{
"extends": [
		"plugin:import/errors",
		"plugin:import/warnings",
		"plugin:import/typescript",
	],
"rules": {
		"import/no-cycle": ["error",
		{
			"maxDepth": 10,
			"ignoreExternal": true
		}],
		"import/no-unresolved": "error",
},
	"settings": {
		"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
		"import/parsers": {
			"@typescript-eslint/parser": [".ts", ".tsx"]
		}
	},
}
⚠️ **GitHub.com Fallback** ⚠️