0
0
Node.jsframework~10 mins

npm initialization and package.json in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Ainit
Binstall
Cstart
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'npm install' instead of 'npm init' to create package.json
Forgetting the '-y' flag to accept defaults
2fill in blank
medium

Complete 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'
Aindex.js
Bapp.json
CREADME.md
Dpackage.json
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'package.json' as main file
Using a non-JavaScript file like README.md
3fill in blank
hard

Fix 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'
Apackage.json
Bindex.js
Cnpm
Dstart.js
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to run 'package.json' as a script
Using a file name that does not exist
4fill in blank
hard

Fill 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'
Ainstall
B--save-dev
C--save
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--save-dev' instead of '--save' for regular dependencies
Using 'update' instead of 'install'
5fill in blank
hard

Fill 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'
Ajest
B--coverage
Dmocha
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