GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - CodingTrain/node-project-demo: Demo for setting up a node.js project

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
words.txt
words.txt
 
 

Repository files navigation

Coding Train Node Demo

Determmining your Node version (v18.18.2 is used in the tutorial)

node --version

Creating a new Node project

  • Make a new Directory
    mkdir coding-train-node-demo

  • Opening / Changing Directories
    cd coding-train-node-demo - open the coding-train-node-demo directory
    . - this current directory
    .. - go back up a level
    code . - open up the VSC editor

Initializing a Node Project

npm init

The utility will walk you some questions--you can enter answers or just say yes.

Node packages

Node documentation

The File System package can be used to access local files on your computer, and is part of node system.

Importing packages

  • CommonJS module
    const fs = require('fs');

  • ES module
    import * as fs from 'fs'

Note: to load an ES module you must edit the package.json file to set "type": "module"

Finding Node Packages

  • npmjs

Some package I will be using:

  • discord.js
  • canvas
  • cowsay

npm install cowsay or npm i cowsay

This will add the package to the package.json as a dependencies. It will also add a new directory called node_modules.

Things to consider when you are looking for packages

  • When was it created?
  • Is it actively maintained?
  • Look at Github repo - are there any recent commits?
  • cowsay repo

Importing the cowsay package

  • Importing everything from a package
    import * as cowsay from 'cowsay'

  • Importing individual functions from a package
    import { say } from 'cowsay'

Downloading and installing an existing Node project

Discord-Bot-Examples

You must install the dependencies for the project.
npm install

Downloading and installing the Coding Train website

Livestream discussing installation of the Coding Train website

When updating the website, it is helpful to run the website locally in order to quickly see the changes made. Make sure you have Node.js version 18.x installed and then perform the following steps:

  1. Clone down the repo to your computer and cd into the folder
  2. Run npm install
  3. Run npm run dev

This will start a local server and the website will now be accessible on localhost:8000. Changes to most files will be auto-updated in the browser while the website is running.

Note: In some cases, specially when updating loaded content, you need to restart the local server with npm run dev. And in some cases that may fail because of Gatsby's cache usage. If you run npm run clean before npm run dev, that should fix it.

About

Demo for setting up a node.js project

Resources

Readme
MIT license
Activity
Custom properties

Stars

2 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.