Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize a new npm project with default settings.
Node.js
npm [1] -y Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'npm install' instead of 'npm init' to create package.json
Forgetting the '-y' flag to accept defaults
✗ Incorrect
The npm init -y command quickly creates a package.json file with default values.
2fill in blank
mediumComplete the JSON snippet to specify the main entry file in package.json.
Node.js
"main": "[1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'package.json' as main file
Using a non-JavaScript file like README.md
✗ Incorrect
The main field tells Node.js which file to load first, usually index.js.
3fill in blank
hardFix the error in the package.json script to start the app with node.
Node.js
"scripts": { "start": "node [1]" }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to run 'package.json' as a script
Using a file name that does not exist
✗ Incorrect
The start script should run the main JavaScript file, usually index.js.
4fill in blank
hardFill both blanks to add a dependency and save it to package.json.
Node.js
npm [1] express [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--save-dev' instead of '--save' for regular dependencies
Using 'update' instead of 'install'
✗ Incorrect
Use npm install express --save to add express as a dependency in package.json.
5fill in blank
hardFill all three blanks to create a script that runs tests with jest.
Node.js
"scripts": { "test": "[1] [2]" }, "devDependencies": { "[3]": "^29.0.0" }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'mocha' instead of 'jest' when jest is the intended test runner
Forgetting to add jest as a devDependency
✗ Incorrect
The test script runs jest --coverage and jest is added as a devDependency.