mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-08-30 17:05:59 +08:00
fix(curriculum): update Node lecture (#69702)
This commit is contained in:
+15
-47
@@ -285,38 +285,6 @@ For example:
|
||||
node app.js
|
||||
```
|
||||
|
||||
### Create a Node.js Project
|
||||
|
||||
This command creates a new Node.js project by creating a `package.json` file that tracks its details and dependencies.
|
||||
|
||||
```bash
|
||||
npm init
|
||||
```
|
||||
|
||||
When you run the `npm init` command, it will walk you through an interactive CLI guide for setting up the `package.json` file. It will ask you questions for the project name, description, version, etc. If you want to start with a default `package.json` file, you can use the `npm init -y` or `npm init --yes` command.
|
||||
|
||||
### Install a Package
|
||||
|
||||
To install a specific package, run:
|
||||
|
||||
```bash
|
||||
npm install <package>
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```bash
|
||||
npm install express
|
||||
```
|
||||
|
||||
### Install Dependencies
|
||||
|
||||
To install all the dependencies listed in the `package.json` file of a project, run:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
# --questions--
|
||||
|
||||
## --text--
|
||||
@@ -397,37 +365,37 @@ Think about the verb used by `nvm` to indicate which version should be active fo
|
||||
|
||||
## --text--
|
||||
|
||||
A new Node.js project needs to be initialized, setting up the `package.json` file to manage its dependencies and scripts. Which command is used for this purpose?
|
||||
Which command runs a JavaScript file named `app.js` in the currently active Node.js runtime?
|
||||
|
||||
## --answers--
|
||||
|
||||
`npm init`
|
||||
|
||||
---
|
||||
|
||||
`npm start`
|
||||
`run app.js`
|
||||
|
||||
### --feedback--
|
||||
|
||||
The command needs to create the project's foundational file for package management.
|
||||
The command starts with the name of the runtime that executes the file.
|
||||
|
||||
---
|
||||
|
||||
`node init`
|
||||
|
||||
### --feedback--
|
||||
|
||||
The command needs to create the project's foundational file for package management.
|
||||
`node app.js`
|
||||
|
||||
---
|
||||
|
||||
`npm install`
|
||||
`nvm app.js`
|
||||
|
||||
### --feedback--
|
||||
|
||||
The command needs to create the project's foundational file for package management.
|
||||
The command starts with the name of the runtime that executes the file.
|
||||
|
||||
---
|
||||
|
||||
`npm app.js`
|
||||
|
||||
### --feedback--
|
||||
|
||||
The command starts with the name of the runtime that executes the file.
|
||||
|
||||
## --video-solution--
|
||||
|
||||
1
|
||||
2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user