Master npm and yarn vocabulary: package scripts, semantic versioning, package.json fields, and workspace concepts.
0 / 25 completed
1 / 25
In package.json, a 'scripts' field entry like 'build: vite build' is run with:
Named scripts in the 'scripts' field are run with 'npm run '. The 'start', 'test', and 'build' scripts can also be run with 'npm start', 'npm test', etc.
2 / 25
In semantic versioning (semver), a patch version bump (e.g., 1.2.3 to 1.2.4) indicates:
Semantic versioning: MAJOR.MINOR.PATCH. Patch = backward-compatible bug fix. Minor = backward-compatible new feature. Major = breaking change.
3 / 25
The caret (^) in a version range like ^2.3.1 in package.json means:
The caret ^ allows minor and patch updates within the same major version — ^2.3.1 allows 2.3.1 up to (but not including) 3.0.0.
4 / 25
What is a 'peer dependency' in npm?
Peer dependencies are packages that a library expects the host project to provide — React component libraries list React as a peer dependency rather than bundling their own copy.
5 / 25
npm workspaces allow you to:
Workspaces enable monorepo development — packages within the workspace can reference each other without publishing, and dependencies are hoisted to a shared node_modules.
6 / 25
Sarah: 'Hey team, I'm running into a problem with the build process. It's consistently failing after deploying to staging, and the logs show an error related to a missing dependency. I've checked my package.json and it *looks* correct, but I'm not sure how to properly add a peer dependency for this library.'
Which of the following best describes Sarah's situation and what she should consider adding to her project?
Sarah's situation highlights the importance of explicitly managing peer dependencies. A `peerDependencies` section in package.json clearly specifies which packages this library expects to be installed alongside it—typically other libraries that depend on it. This prevents conflicts and ensures the correct versions are used, avoiding unexpected build failures. Option B is incorrect because automatic dependency resolution isn't always reliable; options C and D represent alternative troubleshooting steps but don't address the core issue of peer dependencies.
7 / 25
Liam: 'Hey team, during the code review of PR #123, I noticed you're using a custom build script that calls `node_modules/.bin/some-tool` directly. It's generally better practice to explicitly define aliases in your package.json scripts and then use those aliases instead. This makes the build more reproducible and easier to manage.'
Considering Liam's feedback, which of the following actions should Maria take regarding her project's build script?
Liam's comment highlights a key principle of maintainable projects: reproducibility. Directly calling node_modules/.bin/some-tool relies on the specific environment setup and can break if dependencies change or are updated. Defining an alias in package.json creates a more reliable and consistent build process, making it easier to manage dependencies and ensures that the tool is always available via npm scripts. Option B is the most direct and recommended solution.
8 / 25
During a code review of a pull request for a new React component library, David comments: 'I noticed you're directly importing components from the `src/components` directory. While it works now, it's not ideal for maintainability – we should be using npm packages instead. Could you consider publishing this as an npm package?' Maria responds to David with the following message:
'Okay, I understand your point. I've added a npm install command to my project's `package.json` file to manage the component library dependency. It seems to be working fine.'
Which of the following statements best reflects Maria's approach and the potential issue she might be facing?
Maria's approach of simply using npm install to manage a locally developed component is not ideal. While it fulfills the immediate requirement of having the dependency available in her project, it doesn't address the long-term maintainability and potential for reuse that David was highlighting. The core issue is that this component should be treated as an npm package – meaning it needs versioning (using semver), a proper package.json file with scripts for building and testing, and potentially publishing to npm itself. Option 3 correctly identifies this misunderstanding.
9 / 25
John: 'Hey team, I'm trying to automate the deployment process using npm scripts. I've added a script called `deploy` that runs `npm run build` and then `npm run deploy:staging`. However, when I execute npm run deploy, it seems to only run the `build` script once, even though there's also a `deploy:staging` script defined. I'm not sure why this is happening.'
Which of the following best explains what might be occurring and how John should troubleshoot this issue?
This scenario highlights an important detail about how npm scripts are executed: they run sequentially in the order specified within the package.json file. When John uses `npm run deploy`, it executes the script named 'deploy' which then runs the `build` script before running any other defined scripts. Therefore, using `npm run deploy:staging` would directly execute the staging deployment script without triggering the build step first; reordering the scripts in package.json wouldn't fix this fundamental behavior.
10 / 25
During a code review of PR #456, Ben observes that Alex is using the command `npm install --save-dev eslint` in his project's root directory. He asks Alex: 'I noticed you're installing ESLint as a dev dependency. Do you have any specific configuration or scripts set up to run it during development? Are you intending to use it for linting and formatting, or just as a tool that needs to be available in the project?' Alex responds: 'No, I just wanted to make sure it was installed. I'm not using it yet.' Considering Ben's feedback, what is the MOST appropriate action Alex should take regarding ESLint?
The correct answer is that Alex should add a configuration file and define some basic rules. Simply installing ESLint as a dev dependency doesn't actually *use* it; he needs to configure it to tell it what to check for. Options A and B are too drastic – removing the dependency without configuring it won't solve anything. Option C is incorrect because npm handles dependencies, but not configuration, and option D suggests unnecessary escalation when a simple solution exists. Configuring ESLint allows Alex to actually leverage its functionality during development.
11 / 25
Sarah: 'Hey team, I'm running into a problem with the build process. It's consistently failing after deploying to staging, and the logs show an error related to a missing dependency. I've checked my package.json and it *looks* correct, but I'm not sure how to properly add a peer dependency for this library.'
Which of the following best describes Sarah's situation and what she should consider adding to her project?
Sarah's situation highlights the importance of explicitly managing peer dependencies. A `peerDependencies` section in package.json clearly specifies which packages this library expects to be installed alongside it—typically other libraries that depend on it. This prevents conflicts and ensures the correct versions are used, avoiding unexpected build failures. Option B is incorrect because automatic dependency resolution isn't always reliable; options C and D represent alternative troubleshooting steps but don't address the core issue of peer dependencies.
12 / 25
Liam: 'Hey team, during the code review of PR #123, I noticed you're using a custom build script that calls `node_modules/.bin/some-tool` directly. It's generally better practice to explicitly define aliases in your package.json scripts and then use those aliases instead. This makes the build more reproducible and easier to manage.'
Considering Liam's feedback, which of the following actions should Maria take regarding her project's build script?
Liam's comment highlights a key principle of maintainable projects: reproducibility. Directly calling node_modules/.bin/some-tool relies on the specific environment setup and can break if dependencies change or are updated. Defining an alias in package.json creates a more reliable and consistent build process, making it easier to manage dependencies and ensures that the tool is always available via npm scripts. Option B is the most direct and recommended solution.
13 / 25
During a code review of a pull request for a new React component library, David comments: 'I noticed you're directly importing components from the `src/components` directory. While it works now, it's not ideal for maintainability – we should be using npm packages instead. Could you consider publishing this as an npm package?' Maria responds to David with the following message:
'Okay, I understand your point. I've added a npm install command to my project's `package.json` file to manage the component library dependency. It seems to be working fine.'
Which of the following statements best reflects Maria's approach and the potential issue she might be facing?
Maria's approach of simply using npm install to manage a locally developed component is not ideal. While it fulfills the immediate requirement of having the dependency available in her project, it doesn't address the long-term maintainability and potential for reuse that David was highlighting. The core issue is that this component should be treated as an npm package – meaning it needs versioning (using semver), a proper package.json file with scripts for building and testing, and potentially publishing to npm itself. Option 3 correctly identifies this misunderstanding.
14 / 25
John: 'Hey team, I'm trying to automate the deployment process using npm scripts. I've added a script called `deploy` that runs `npm run build` and then `npm run deploy:staging`. However, when I execute npm run deploy, it seems to only run the `build` script once, even though there's also a `deploy:staging` script defined. I'm not sure why this is happening.'
Which of the following best explains what might be occurring and how John should troubleshoot this issue?
This scenario highlights an important detail about how npm scripts are executed: they run sequentially in the order specified within the package.json file. When John uses `npm run deploy`, it executes the script named 'deploy' which then runs the `build` script before running any other defined scripts. Therefore, using `npm run deploy:staging` would directly execute the staging deployment script without triggering the build step first; reordering the scripts in package.json wouldn't fix this fundamental behavior.
15 / 25
During a code review of PR #456, Ben observes that Alex is using the command `npm install --save-dev eslint` in his project's root directory. He asks Alex: 'I noticed you're installing ESLint as a dev dependency. Do you have any specific configuration or scripts set up to run it during development? Are you intending to use it for linting and formatting, or just as a tool that needs to be available in the project?' Alex responds: 'No, I just wanted to make sure it was installed. I'm not using it yet.' Considering Ben's feedback, what is the MOST appropriate action Alex should take regarding ESLint?
The correct answer is that Alex should add a configuration file and define some basic rules. Simply installing ESLint as a dev dependency doesn't actually *use* it; he needs to configure it to tell it what to check for. Options A and B are too drastic – removing the dependency without configuring it won't solve anything. Option C is incorrect because npm handles dependencies, but not configuration, and option D suggests unnecessary escalation when a simple solution exists. Configuring ESLint allows Alex to actually leverage its functionality during development.
16 / 25
Sarah: 'Hey team, I'm running into a problem with the build process. It's consistently failing after deploying to staging, and the logs show an error related to a missing dependency. I've checked my package.json and it *looks* correct, but I'm not sure how to properly add a peer dependency for this library.'
Which of the following best describes Sarah's situation and what she should consider adding to her project?
Sarah's situation highlights the importance of explicitly managing peer dependencies. A `peerDependencies` section in package.json clearly specifies which packages this library expects to be installed alongside it—typically other libraries that depend on it. This prevents conflicts and ensures the correct versions are used, avoiding unexpected build failures. Option B is incorrect because automatic dependency resolution isn't always reliable; options C and D represent alternative troubleshooting steps but don't address the core issue of peer dependencies.
17 / 25
Liam: 'Hey team, during the code review of PR #123, I noticed you're using a custom build script that calls `node_modules/.bin/some-tool` directly. It's generally better practice to explicitly define aliases in your package.json scripts and then use those aliases instead. This makes the build more reproducible and easier to manage.'
Considering Liam's feedback, which of the following actions should Maria take regarding her project's build script?
Liam's comment highlights a key principle of maintainable projects: reproducibility. Directly calling node_modules/.bin/some-tool relies on the specific environment setup and can break if dependencies change or are updated. Defining an alias in package.json creates a more reliable and consistent build process, making it easier to manage dependencies and ensures that the tool is always available via npm scripts. Option B is the most direct and recommended solution.
18 / 25
During a code review of a pull request for a new React component library, David comments: 'I noticed you're directly importing components from the `src/components` directory. While it works now, it's not ideal for maintainability – we should be using npm packages instead. Could you consider publishing this as an npm package?' Maria responds to David with the following message:
'Okay, I understand your point. I've added a npm install command to my project's `package.json` file to manage the component library dependency. It seems to be working fine.'
Which of the following statements best reflects Maria's approach and the potential issue she might be facing?
Maria's approach of simply using npm install to manage a locally developed component is not ideal. While it fulfills the immediate requirement of having the dependency available in her project, it doesn't address the long-term maintainability and potential for reuse that David was highlighting. The core issue is that this component should be treated as an npm package – meaning it needs versioning (using semver), a proper package.json file with scripts for building and testing, and potentially publishing to npm itself. Option 3 correctly identifies this misunderstanding.
19 / 25
John: 'Hey team, I'm trying to automate the deployment process using npm scripts. I've added a script called `deploy` that runs `npm run build` and then `npm run deploy:staging`. However, when I execute npm run deploy, it seems to only run the `build` script once, even though there's also a `deploy:staging` script defined. I'm not sure why this is happening.'
Which of the following best explains what might be occurring and how John should troubleshoot this issue?
This scenario highlights an important detail about how npm scripts are executed: they run sequentially in the order specified within the package.json file. When John uses `npm run deploy`, it executes the script named 'deploy' which then runs the `build` script before running any other defined scripts. Therefore, using `npm run deploy:staging` would directly execute the staging deployment script without triggering the build step first; reordering the scripts in package.json wouldn't fix this fundamental behavior.
20 / 25
During a code review of PR #456, Ben observes that Alex is using the command `npm install --save-dev eslint` in his project's root directory. He asks Alex: 'I noticed you're installing ESLint as a dev dependency. Do you have any specific configuration or scripts set up to run it during development? Are you intending to use it for linting and formatting, or just as a tool that needs to be available in the project?' Alex responds: 'No, I just wanted to make sure it was installed. I'm not using it yet.' Considering Ben's feedback, what is the MOST appropriate action Alex should take regarding ESLint?
The correct answer is that Alex should add a configuration file and define some basic rules. Simply installing ESLint as a dev dependency doesn't actually *use* it; he needs to configure it to tell it what to check for. Options A and B are too drastic – removing the dependency without configuring it won't solve anything. Option C is incorrect because npm handles dependencies, but not configuration, and option D suggests unnecessary escalation when a simple solution exists. Configuring ESLint allows Alex to actually leverage its functionality during development.
21 / 25
Sarah: 'Hey team, I'm running into a problem with the build process. It's consistently failing after deploying to staging, and the logs show an error related to a missing dependency. I've checked my package.json and it *looks* correct, but I'm not sure how to properly add a peer dependency for this library.'
Which of the following best describes Sarah's situation and what she should consider adding to her project?
Sarah's situation highlights the importance of explicitly managing peer dependencies. A `peerDependencies` section in package.json clearly specifies which packages this library expects to be installed alongside it—typically other libraries that depend on it. This prevents conflicts and ensures the correct versions are used, avoiding unexpected build failures. Option B is incorrect because automatic dependency resolution isn't always reliable; options C and D represent alternative troubleshooting steps but don't address the core issue of peer dependencies.
22 / 25
Liam: 'Hey team, during the code review of PR #123, I noticed you're using a custom build script that calls `node_modules/.bin/some-tool` directly. It's generally better practice to explicitly define aliases in your package.json scripts and then use those aliases instead. This makes the build more reproducible and easier to manage.'
Considering Liam's feedback, which of the following actions should Maria take regarding her project's build script?
Liam's comment highlights a key principle of maintainable projects: reproducibility. Directly calling node_modules/.bin/some-tool relies on the specific environment setup and can break if dependencies change or are updated. Defining an alias in package.json creates a more reliable and consistent build process, making it easier to manage dependencies and ensures that the tool is always available via npm scripts. Option B is the most direct and recommended solution.
23 / 25
During a code review of a pull request for a new React component library, David comments: 'I noticed you're directly importing components from the `src/components` directory. While it works now, it's not ideal for maintainability – we should be using npm packages instead. Could you consider publishing this as an npm package?' Maria responds to David with the following message:
'Okay, I understand your point. I've added a npm install command to my project's `package.json` file to manage the component library dependency. It seems to be working fine.'
Which of the following statements best reflects Maria's approach and the potential issue she might be facing?
Maria's approach of simply using npm install to manage a locally developed component is not ideal. While it fulfills the immediate requirement of having the dependency available in her project, it doesn't address the long-term maintainability and potential for reuse that David was highlighting. The core issue is that this component should be treated as an npm package – meaning it needs versioning (using semver), a proper package.json file with scripts for building and testing, and potentially publishing to npm itself. Option 3 correctly identifies this misunderstanding.
24 / 25
John: 'Hey team, I'm trying to automate the deployment process using npm scripts. I've added a script called `deploy` that runs `npm run build` and then `npm run deploy:staging`. However, when I execute npm run deploy, it seems to only run the `build` script once, even though there's also a `deploy:staging` script defined. I'm not sure why this is happening.'
Which of the following best explains what might be occurring and how John should troubleshoot this issue?
This scenario highlights an important detail about how npm scripts are executed: they run sequentially in the order specified within the package.json file. When John uses `npm run deploy`, it executes the script named 'deploy' which then runs the `build` script before running any other defined scripts. Therefore, using `npm run deploy:staging` would directly execute the staging deployment script without triggering the build step first; reordering the scripts in package.json wouldn't fix this fundamental behavior.
25 / 25
During a code review of PR #456, Ben observes that Alex is using the command `npm install --save-dev eslint` in his project's root directory. He asks Alex: 'I noticed you're installing ESLint as a dev dependency. Do you have any specific configuration or scripts set up to run it during development? Are you intending to use it for linting and formatting, or just as a tool that needs to be available in the project?' Alex responds: 'No, I just wanted to make sure it was installed. I'm not using it yet.' Considering Ben's feedback, what is the MOST appropriate action Alex should take regarding ESLint?
The correct answer is that Alex should add a configuration file and define some basic rules. Simply installing ESLint as a dev dependency doesn't actually *use* it; he needs to configure it to tell it what to check for. Options A and B are too drastic – removing the dependency without configuring it won't solve anything. Option C is incorrect because npm handles dependencies, but not configuration, and option D suggests unnecessary escalation when a simple solution exists. Configuring ESLint allows Alex to actually leverage its functionality during development.
What does the "npm & Package Scripts Vocabulary" exercise cover?
Master npm and yarn vocabulary: package scripts, semantic versioning, package.json fields, and workspace concepts.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to use with no account, sign-up, or paywall.
How many questions are in "npm & Package Scripts Vocabulary"?
This exercise has 25 questions. Each one gives instant feedback with an explanation, so you can see exactly why an answer is right or wrong.
Do I need to create an account to save my progress?
No account is required. The progress bar and score are tracked in your browser for the current session -- the exercise is designed to be a quick, repeatable drill rather than something you resume later.
What happens if I get an answer wrong?
You'll see the correct answer highlighted immediately, along with a short explanation of why it's correct. Wrong answers aren't penalized beyond your score, and you can keep going through every question.
How is this exercise different from reading an article?
Articles explain vocabulary and concepts through prose, while exercises like this one are interactive drills -- multiple-choice questions -- that test and reinforce your recall of specific terms and phrasing.
Can I retry this exercise?
Yes -- use the "Try again" button on the results screen to reset your score and go through all the questions again from the start.
Where can I find more Developer Toolchain exercises?
Browse the full Developer Toolchain hub for related drills, or check the site-wide exercises index for other IT English topics.
Is this exercise suitable for beginners?
This exercise assumes basic familiarity with IT terminology. If a term feels unfamiliar, check the site Glossary for a plain-English definition before attempting the questions.
How often is new content like this published?
New exercises are added regularly across all categories, alongside new vocabulary sets and articles. Check back on the exercises hub to see what's new.