npm Development Dependencies

This article introduces npm development dependencies, including their advantages, implementation details, and related resources. These concepts can help improve the efficiency of managing npm development dependencies.

May 26, 2022 · 1 min read · 155 Words · -Views -Comments · Programming
Node.js 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

When managing package dependencies, there are both dependencies and development dependencies. Third-party packages that are installed also have their own dependencies and development dependencies. The installation logic for these package dependencies needs to be clarified.

npm i

During local development, we typically run npm i, which installs both direct dependencies and direct development dependencies. However, development dependencies of third-party packages are not installed. This makes sense because packages themselves are published and considered to be in production mode, so there’s no need to install their development dependencies.

Of course, with dependencies and indirect dependencies plus package versions, multiple versions of the same package can coexist, which is also important to note.

–production

When running npm i, you can specify the mode explicitly. In production mode, development dependencies are not installed. This is mainly used when deploying Node.js services to production, where development-related packages (like TypeScript) are often not needed. This can further improve deployment speed.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover