Challenge - 5 Problems
Node.js Package Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding dependencies vs devDependencies
Which statement correctly describes the difference between dependencies and devDependencies in a Node.js project?
Attempts:
2 left
💡 Hint
Think about which packages your app needs when it runs versus when you write or test it.
✗ Incorrect
Dependencies are packages your app needs to run in production. DevDependencies are only needed during development, like testing or building tools.
❓ component_behavior
intermediate2:00remaining
Effect of installing a package with --save-dev
What happens when you run
npm install eslint --save-dev in your project?Attempts:
2 left
💡 Hint
Consider where the package is listed in package.json after this command.
✗ Incorrect
The --save-dev flag adds the package to devDependencies and installs it locally.
📝 Syntax
advanced2: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"
}
}Attempts:
2 left
💡 Hint
Look for the caret symbol and what it means for versioning.
✗ Incorrect
The caret (^) means compatible with version 4.18.2, allowing minor updates but not major ones.
❓ state_output
advanced2: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?Attempts:
2 left
💡 Hint
Think about what npm does by default when installing packages.
✗ Incorrect
By default, npm install installs both dependencies and devDependencies locally, even if package-lock.json is missing.
🔧 Debug
expert3: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?Attempts:
2 left
💡 Hint
Consider what happens when you install packages in production mode.
✗ Incorrect
When running npm install --production, npm skips installing devDependencies, so the package is missing in production.