npm initμ μ€ννμ¬ μ Node.js νλ‘μ νΈ λλ ν°λ¦¬λ₯Ό λ§λ€ λ, npmμ package.json νμΌμ μμ±νκΈ° μν΄ μ¬λ¬ μ§λ¬Έμ λμ§λλ€. package.json νμΌμ νλ‘μ νΈμ ν΅μ¬ μ€μ νμΌμ
λλ€. μ§λ¬Έκ³Ό κ·Έ μλ―Έμ λν μ€λͺ
μ λ€μκ³Ό κ°μ΅λλ€.
package name:(νμ)- νλ‘μ νΈμ μ΄λ¦μ λλ€. μ§§κ³ μλ¬Έμλ‘, 곡백 μμ΄ μμ±νλ κ²μ΄ μ’μ΅λλ€. νμ΄νκ³Ό μΈλμ€μ½μ΄λ νμ©λ©λλ€. μ΄ μ΄λ¦μ λμ€μ npm λ μ§μ€νΈλ¦¬μ ν¨ν€μ§λ₯Ό κ²μν λ μ¬μ©λ©λλ€ (κ²μν κ³νμ΄ μλ κ²½μ°). κ²μν κ³νμ΄ μλλΌλ μ€λͺ μ μΈ μ΄λ¦μ μ¬μ©ν μ μμ΅λλ€.
- κΈ°λ³Έκ°: νμ¬ λλ ν°λ¦¬μ μ΄λ¦.
- μμ:
my-awesome-project
version:(νμ)- νλ‘μ νΈμ νμ¬ λ²μ μ
λλ€. μλ§¨ν± λ²μ (semver) κ·μΉ(μ:
1.0.0,0.1.0,2.5.3-beta)μ λ°λ¦ λλ€. - κΈ°λ³Έκ°:
1.0.0 - μμ:
0.0.1(μμ£Ό μ΄κΈ° λ¨κ³μ νλ‘μ νΈμΈ κ²½μ°)
- νλ‘μ νΈμ νμ¬ λ²μ μ
λλ€. μλ§¨ν± λ²μ (semver) κ·μΉ(μ:
description:(μ ν μ¬ν)- νλ‘μ νΈμ λν κ°λ΅ν μ€λͺ μ λλ€. npmμμ ν¨ν€μ§λ₯Ό κ²μνκ±°λ GitHubκ³Ό κ°μ νλ«νΌμμ νλ‘μ νΈλ₯Ό λ³Ό λ νμλ©λλ€.
- κΈ°λ³Έκ°: (λΉμ΄ μμ)
- μμ:
λ¬Έμμ΄ μ‘°μμ μν κ°λ¨ν μ νΈλ¦¬ν° λΌμ΄λΈλ¬λ¦¬μ λλ€.
entry point:(νμ)- ν¨ν€μ§κ° λͺ¨λλ‘ μ¬μ©λ λ μ€νλ κΈ°λ³Έ νμΌμ λλ€. μμ© νλ‘κ·Έλ¨μ μ§μ μ μ λλ€.
- κΈ°λ³Έκ°:
index.js - μμ:
main.js,app.js
test command:(μ ν μ¬ν)npm testλ₯Ό μ€νν λ npmμ΄ μ€νν λͺ λ Ήμ λλ€. νλ‘μ νΈμ ν μ€νΈλ₯Ό μ€ννλ λ° μ¬μ©λ©λλ€.- κΈ°λ³Έκ°: (λΉμ΄ μμ)
- μμ:
jest,mocha
git repository:(μ ν μ¬ν)- νλ‘μ νΈμ Git μ μ₯μ URLμ
λλ€ (μ:
https://github.com/yourusername/my-awesome-project). μ’ μμ± κ΄λ¦¬ λ° νμ μ λμμ΄ λ©λλ€. - κΈ°λ³Έκ°: (λΉμ΄ μμ)
- μμ:
github.com/yourusername/my-awesome-project(Git μ μ₯μμ μλ κ²½μ° npmμ΄ μ’ μ’ μ΄λ₯Ό μΆλ‘ ν μ μμ΅λλ€.)
- νλ‘μ νΈμ Git μ μ₯μ URLμ
λλ€ (μ:
keywords:(μ ν μ¬ν)- νλ‘μ νΈλ₯Ό μ€λͺ νλ ν€μλ λͺ©λ‘μ λλ€. μ¬λλ€μ΄ npmμμ κ²μν λ ν¨ν€μ§λ₯Ό μ°Ύλ λ° λμμ΄ λ©λλ€.
- κΈ°λ³Έκ°: (λΉμ΄ μμ)
- μμ:
string, utility, manipulation
author:(μ ν μ¬ν)- λΉμ μ μ΄λ¦ λ°/λλ μ΄λ©μΌ μ£Όμμ λλ€.
- κΈ°λ³Έκ°: (λΉμ΄ μμ)
- μμ:
John Doe <john.doe@example.com>
license:(νμ)- νλ‘μ νΈκ° λ°°ν¬λλ λΌμ΄μ μ€μ λλ€ (μ: MIT, ISC, GPLv3). λΌμ΄μ μ€ μ νμ λ²μ μΌλ‘ μ€μν©λλ€.
- κΈ°λ³Έκ°:
ISC - μμ:
MIT
About to write to /path/to/your/project/package.json: ...- μμ±λ
package.jsonνμΌμ λ΄μ©μ 보μ¬μ£Όλ νμΈ λ©μμ§μ λλ€. νμΌμ μμ±νκΈ° μ μ μ 보λ₯Ό κ²ν ν μ μμ΅λλ€.
- μμ±λ
Is this OK?yesλλyλ₯Ό μ λ ₯νμ¬ νμΈνκ³package.jsonνμΌμ μμ±ν©λλ€.noλλnμ μ λ ₯νμ¬ μ·¨μν©λλ€.
μ΄λ¬ν μ§λ¬Έμ λ΅λ³νκ±°λ Enter ν€λ₯Ό λλ¬ κΈ°λ³Έκ°μ μ μ©νλ©΄ npmμ νλ‘μ νΈ λλ ν°λ¦¬μ package.json νμΌμ μμ±ν©λλ€. μ΄ νμΌμλ μ 곡ν λͺ¨λ μ λ³΄κ° ν¬ν¨λ©λλ€. κ·Έλ° λ€μ μ’
μμ±μ μ€μΉνκ³ Node.js μμ© νλ‘κ·Έλ¨ κ°λ°μ μμν μ μμ΅λλ€.
When you run npm init in a new Node.js project directory, npm walks you through a series of questions to create a package.json file, which is the core configuration file for your project. Here’s a breakdown of the questions and what they mean:
package name:(required)- This is the name of your project. It should be a short, lowercase name, preferably without spaces. Hyphens and underscores are allowed. This name will be used when publishing your package to the npm registry (if you intend to do that later). If you don’t plan to publish, you can still use a descriptive name.
- Default: The name of the current directory.
- Example:
my-awesome-project
version:(required)- The current version of your project. It follows semantic versioning (semver) principles (e.g.,
1.0.0,0.1.0,2.5.3-beta). - Default:
1.0.0 - Example:
0.0.1(for a very early stage project)
- The current version of your project. It follows semantic versioning (semver) principles (e.g.,
description:(optional)- A brief description of your project. This is displayed when people search for packages on npm or view your project on platforms like GitHub.
- Default: (blank)
- Example:
A simple utility library for string manipulation.
entry point:(required)- The main file that will be executed when your package is used as a module. This is the entry point of your application.
- Default:
index.js - Example:
main.js,app.js
test command:(optional)- The command that npm will run when you execute
npm test. This is used for running your project’s tests. - Default: (blank)
- Example:
jest,mocha
- The command that npm will run when you execute
git repository:(optional)- The URL of your project’s Git repository (e.g.,
https://github.com/yourusername/my-awesome-project). This helps with dependency management and collaboration. - Default: (blank)
- Example:
github.com/yourusername/my-awesome-project(npm can often infer this if you’re in a git repo)
- The URL of your project’s Git repository (e.g.,
keywords:(optional)- A list of keywords that describe your project. These help people find your package when searching on npm.
- Default: (blank)
- Example:
string, utility, manipulation
author:(optional)- Your name and/or email address.
- Default: (blank)
- Example:
John Doe <john.doe@example.com>
license:(required)- The license under which your project is distributed (e.g., MIT, ISC, GPLv3). Choosing a license is important for legal reasons.
- Default:
ISC - Example:
MIT
About to write to /path/to/your/project/package.json: ...- This is a confirmation message showing you the contents of the
package.jsonfile that will be created. You can review the information before it’s written to the file.
- This is a confirmation message showing you the contents of the
Is this OK?- Type
yesoryto confirm and create thepackage.jsonfile. Typenoornto cancel.
- Type
After you answer these questions (or accept the defaults by pressing Enter), npm will create the package.json file in your project directory. This file will contain all the information you provided. You can then start installing dependencies and developing your Node.js application.