0
0
Node.jsframework~20 mins

Installing packages (dependencies vs devDependencies) in Node.js - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Node.js Package Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding dependencies vs devDependencies
Which statement correctly describes the difference between dependencies and devDependencies in a Node.js project?
Adependencies are required for the app to run in production, devDependencies are only needed during development
BdevDependencies are installed globally, dependencies are installed locally
Cdependencies and devDependencies are the same and can be used interchangeably
Ddependencies are needed only during development, devDependencies are needed in production
Attempts:
2 left
💡 Hint
Think about which packages your app needs when it runs versus when you write or test it.
component_behavior
intermediate
2:00remaining
Effect of installing a package with --save-dev
What happens when you run npm install eslint --save-dev in your project?
Aeslint is installed globally and not added to package.json
Beslint is added to dependencies and installed
Ceslint is added to devDependencies and installed
Deslint is added to dependencies but not installed
Attempts:
2 left
💡 Hint
Consider where the package is listed in package.json after this command.
📝 Syntax
advanced
2:00remaining
Identifying correct package.json entry for dependencies
Given this snippet from package.json, which option correctly shows how a dependency should appear?
Node.js
{
  "dependencies": {
    "express": "^4.18.2"
  },
  "devDependencies": {
    "jest": "^29.5.0"
  }
}
A"express": "^4.18.2"
B"express": "4.18.2"
C"express": "~4.18.2"
D"express": "*"
Attempts:
2 left
💡 Hint
Look for the caret symbol and what it means for versioning.
state_output
advanced
2:00remaining
Result of running npm install without package-lock.json
If your project has a package.json with dependencies and devDependencies but no package-lock.json, what will happen when you run npm install?
ANo packages are installed because package-lock.json is missing
BOnly dependencies are installed, devDependencies are ignored
COnly devDependencies are installed, dependencies are ignored
DBoth dependencies and devDependencies are installed locally
Attempts:
2 left
💡 Hint
Think about what npm does by default when installing packages.
🔧 Debug
expert
3:00remaining
Why does a package installed as devDependency fail in production?
You installed a package with npm install --save-dev some-package. Your app crashes in production saying the package is missing. Why?
AThe package was installed globally and not included in the project
BdevDependencies are not installed when running <code>npm install --production</code> in production
CThe package version is incompatible with production Node.js version
DThe package.json file is corrupted and missing the package entry
Attempts:
2 left
💡 Hint
Consider what happens when you install packages in production mode.