Node.js-> Command Line

Node.js prompts and commands for use with Node.js applications and Node.js development environments.

πŸ“ 65 Prompts

πŸ“š Prompts in this Group

Learn these prompts step by step to master this theme

1

Abort the process on uncaught exceptions

node --abort-on-uncaught-exception app.js
View β†’
2

Assert a Variable.

console.assert(petsArray.length > 5);
View β†’
3

Audit your project for security vulnerabilities

npm audit
View β†’
4

Automatically fix security vulnerabilities

npm audit fix
View β†’
5

Check for outdated packages in your project

npm outdated
View β†’
6

Check the syntax of a file without executing it

node --check script.js
View β†’
7

Clear the npm cache completely

πŸ’‘ --force flag is required for cache cleaning
View β†’
8

Complete the async function:

async function fetchData() { Β Β return awaitPromise .resolve('Hello!'); }
View β†’
9

Complete the code to create your first Node.js application:

let http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hello World!'); }).listen(8080);
View β†’
10

Create a tarball from a package

npm pack
View β†’
11

Disable all warnings

node --no-warnings app.js
View β†’
12

Display modules in REPL

require('module').builtinModules
View β†’
13

Enable experimental ES modules support

node --experimental-modules app.js
View β†’
14

Enable source map support for better stack traces

node --enable-source-maps app.js
View β†’
15

Evaluate JavaScript code directly from command line

node -e "console.log('Hello')"
View β†’
16

Execute a package without installing it globally

npx create-react-app my-app
View β†’
17

Get the path to the npm bin directory

npm bin
View β†’
18

Import OS module using require

const os = require('os');
View β†’
19

Initialize a new Node.js project with package.json

npm init
View β†’
20

Initialize a new Node.js project with package.json shorkey

npm init -y
View β†’
21

Install a package globally to use it as a CLI tool

npm install -g typescript
View β†’
22

Install all dependencies and then remove unused packages in two commands

npm install npm prune
View β†’
23

Install all dependencies listed in package.json

npm install
View β†’
24

Install an exact version of a package

npm install --save-exact lodash
View β†’
25

Install Express.js as a production dependency

npm install express
View β†’
26

Install nodemon as a development dependency

npm install --save-dev nodemon
View β†’
27

Install NPM.

install npm [package name]
View β†’
28

Install packages from package.json using only the lockfile

npm ci
View β†’
29

Link a package globally for development

npm link
View β†’
30

List all installed packages in the current project

npm list
View β†’
31

Login to your npm account

npm login
View β†’
32

Node.js line command installation through WINGET

winget install OpenJS.NodeJS
View β†’
33

Node.js line command uninstallation through WINGET

winget uninstall OpenJS.NodeJS
View β†’
34

Node.js path selection

[Environment]::SetEnvironmentVariable("Path", "C:\Program Files\nodejs;" + [Environment]::GetEnvironmentVariable("Path", "User"), "User")
View β†’
35

Open the npm documentation in browser

npm help install
View β†’
36

Print an array in the console

console.log(petsArray);
View β†’
37

Print array in a table.

console.table(petsArray);
View β†’
38

Print the result of evaluated expressions

node -p "2 + 2"
View β†’
39

Rebuild native addons

npm rebuild
View β†’
40

Remove extraneous packages not in package.json

npm prune
View β†’
41

Require a module before executing the main script

node -r dotenv/config app.js
View β†’
42

Run a custom script called "dev" from package.json

npm run dev
View β†’
43

Run a Node.js script and enable strict mode

node --use-strict script.js
View β†’
44

run app in node.js

node app.js
View β†’
45

Run Node.js with zero-turnaround using watch mode

node --watch app.js
View β†’
46

Run npm install without generating a lockfile

npm install --no-package-lock
View β†’
47

Run REPL

node
View β†’
48

Run the "start" script defined in package.json

npm start
View β†’
49

Run the "test" script defined in package.json

npm test
View β†’
50

Search for packages on npm registry

npm search express
View β†’
51

Set an environment variable inline when running Node.js

NODE_ENV=production node app.js
View β†’
52

Set the maximum old space size for V8 heap memory to 4GB

node --max-old-space-size=4096 app.js
View β†’
53

Show deprecation warnings

node --trace-deprecation app.js
View β†’
54

Show full stack traces for warnings

node --trace-warnings app.js
View β†’
55

Show the current logged-in npm user

npm whoami
View β†’
56

Start Node.js in debug mode and break before user code starts

node --inspect-brk app.js
View β†’
57

Start Node.js in debug mode with inspector enabled

node --inspect app.js
View β†’
58

Start the Node.js REPL (Read-Eval-Print Loop) interactive shell

node
View β†’
59

Two ways to install dependencies from package.json

npm install npm ci
View β†’
60

Uninstall a package from your project name (lodash)

npm uninstall lodash
View β†’
61

Update all packages to their latest versions

npm update
View β†’
62

Verify node.js existence through command line.

node -v
View β†’
63

Verify NPM existence through command line.

npm -v
View β†’
64

View information about a package on npm registry

npm view react
View β†’
65

What npm command do you use to install the http-server package globally?

npm install http-server -g
View β†’

🎯 Learning Progress

0 / 65 completed
🧠 Practice with Quiz