• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Types of dependencies in package.json file

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Let’s break down each type of dependency in package.json in detail:

1. Dependencies ("dependencies")

  • These are the essential packages required for your project to run in production.
  • They are installed automatically when you run npm install or yarn install.
  • Example: If you're building a React application, react and react-dom would be dependencies.
  • Defined like this in package.json:

"dependencies": {
"react": "^18.0.0",
"redux": "^4.1.0"
}
  • When you deploy your application, these packages are included.
2. DevDependencies ("devDependencies")

  • These packages are only needed during development (e.g., testing tools, linters, build tools).
  • They won’t be included in the production build.
  • Example: Testing frameworks like jest or bundlers like webpack.
  • Installed with:

npm install --save-dev jest
  • Defined in package.json like this:

"devDependencies": {
"jest": "^29.0.0",
"eslint": "^8.0.0"
}
3. PeerDependencies ("peerDependencies")

  • These are dependencies that the package expects to exist in the user's environment.
  • They don’t get installed automatically but must be provided by the host project.
  • Example: A UI library might list react as a peer dependency so users can use their own version.
  • Defined like this:

"peerDependencies": {
"react": "^18.0.0"
}
  • If a required peer dependency isn’t installed, a warning will be displayed.
4. OptionalDependencies ("optionalDependencies")

  • These dependencies are not mandatory but can enhance functionality.
  • If an optional dependency fails to install, the package manager won’t break the installation process.
  • Example: A package might include a database driver as an optional dependency that users can choose to install.
  • Defined like this:

"optionalDependencies": {
"sqlite3": "^5.0.0"
}
5. BundledDependencies ("bundledDependencies")

  • These dependencies are packaged together when distributing the application.
  • Useful when creating a CLI tool or library that should bundle certain dependencies for consistency.
  • Example:

"bundledDependencies": ["lodash", "moment"]
  • Ensures that these dependencies are always included.

Each type of dependency serves a different purpose in managing the project’s requirements effectively.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу