curriculum icon indicating copy to clipboard operation
curriculum copied to clipboard

Express 101: Use of `--git` flag of `express-generator` for the `.gitignore` file

Open mark-P0 opened this issue 1 year ago • 3 comments

Checks

Describe your suggestion

The Using Git section instructs about making a .gitignore file manually and adding node_modules there.

However, express-generator also accepts a --git flag for generating a .gitignore file that also includes node_modules. I think it is preferable to let the tool handle this "step" for us.

From the MDN tutorial:
> express --help

    Usage: express [options] [dir]

  Options:

        --version        output the version number
    -e, --ejs            add ejs engine support
        --pug            add pug engine support
        --hbs            add handlebars engine support
    -H, --hogan          add hogan.js engine support
    -v, --view <engine>  add view <engine> support (dust|ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)
        --no-view        use static html instead of view engine
    -c, --css <engine>   add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain CSS)
        --git            add .gitignore
    -f, --force          force on non-empty directory
    -h, --help           output usage information
Content of the generated file:
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

 

I understand if this is undesirable since there is a lot of other things in the generated .gitignore (although Vite's .gitignore in the React course is also kind of verbose 😅). Maybe the use of the --git flag can just be suggested as an alternative.

Possible edit:

Using Git

As you work through this tutorial, make sure to put the node_modules folder in a .gitignore file.

Alternatively, you can also use the --git flag of express-generator, e.g.

express express-locallibrary-tutorial --view=pug --git

I am not sure if this fits well enough here though, since the discussion around express-generator is in the MDN tutorial.

Path

Node / JS

Lesson Url

https://www.theodinproject.com/lessons/nodejs-express-101

(Optional) Discord Name

E('Mark')

(Optional) Additional Comments

No response

mark-P0 avatar Jan 23 '24 22:01 mark-P0

Thank you for the suggestion @mark-P0

Going to ping our @TheOdinProject/javascript team and ask for their input on this.

JoshDevHub avatar Jan 25 '24 05:01 JoshDevHub

This issue is stale because it has had no activity for the last 30 days.

github-actions[bot] avatar Feb 25 '24 01:02 github-actions[bot]

Unless there's any issues that arise from using the flag (like "You can use this flag, but be sure to/keep in mind..."), I don't think it's really necessary to add that in. At this point users should be used to adding files to a gitignore file, so the "Using git" section actually seems unnecessary as well. If users reading the MDN tutorial notice the --git flag being mentioned it'd be more up to them whether to use it or not.

thatblindgeye avatar Feb 25 '24 13:02 thatblindgeye

This issue is stale because it has had no activity for the last 30 days.

github-actions[bot] avatar Mar 28 '24 01:03 github-actions[bot]

Gonna close this for now as it doesn't really feel like a necessary change still, but willing to reopen if anyone feels strongly about it.

thatblindgeye avatar Mar 30 '24 13:03 thatblindgeye