[nodejs]facebook nodejs-1

npm init을 μ‹€ν–‰ν•˜μ—¬ μƒˆ Node.js ν”„λ‘œμ νŠΈ 디렉터리λ₯Ό λ§Œλ“€ λ•Œ, npm은 package.json νŒŒμΌμ„ μƒμ„±ν•˜κΈ° μœ„ν•΄ μ—¬λŸ¬ μ§ˆλ¬Έμ„ λ˜μ§‘λ‹ˆλ‹€. package.json νŒŒμΌμ€ ν”„λ‘œμ νŠΈμ˜ 핡심 μ„€μ • νŒŒμΌμž…λ‹ˆλ‹€. 질문과 κ·Έ μ˜λ―Έμ— λŒ€ν•œ μ„€λͺ…은 λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

  1. package name: (ν•„μˆ˜)
    • ν”„λ‘œμ νŠΈμ˜ μ΄λ¦„μž…λ‹ˆλ‹€. μ§§κ³  μ†Œλ¬Έμžλ‘œ, 곡백 없이 μž‘μ„±ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. ν•˜μ΄ν”ˆκ³Ό μ–Έλ”μŠ€μ½”μ–΄λŠ” ν—ˆμš©λ©λ‹ˆλ‹€. 이 이름은 λ‚˜μ€‘μ— npm λ ˆμ§€μŠ€νŠΈλ¦¬μ— νŒ¨ν‚€μ§€λ₯Ό κ²Œμ‹œν•  λ•Œ μ‚¬μš©λ©λ‹ˆλ‹€ (κ²Œμ‹œν•  κ³„νšμ΄ μžˆλŠ” 경우). κ²Œμ‹œν•  κ³„νšμ΄ 없더라도 μ„€λͺ…적인 이름을 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: ν˜„μž¬ λ””λ ‰ν„°λ¦¬μ˜ 이름.
    • μ˜ˆμ‹œ: my-awesome-project
  2. version: (ν•„μˆ˜)
    • ν”„λ‘œμ νŠΈμ˜ ν˜„μž¬ λ²„μ „μž…λ‹ˆλ‹€. μ‹œλ§¨ν‹± 버전(semver) κ·œμΉ™(예: 1.0.0, 0.1.0, 2.5.3-beta)을 λ”°λ¦…λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: 1.0.0
    • μ˜ˆμ‹œ: 0.0.1 (μ•„μ£Ό 초기 λ‹¨κ³„μ˜ ν”„λ‘œμ νŠΈμΈ 경우)
  3. description: (선택 사항)
    • ν”„λ‘œμ νŠΈμ— λŒ€ν•œ κ°„λž΅ν•œ μ„€λͺ…μž…λ‹ˆλ‹€. npmμ—μ„œ νŒ¨ν‚€μ§€λ₯Ό κ²€μƒ‰ν•˜κ±°λ‚˜ GitHubκ³Ό 같은 ν”Œλž«νΌμ—μ„œ ν”„λ‘œμ νŠΈλ₯Ό λ³Ό λ•Œ ν‘œμ‹œλ©λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: (λΉ„μ–΄ 있음)
    • μ˜ˆμ‹œ: λ¬Έμžμ—΄ μ‘°μž‘μ„ μœ„ν•œ κ°„λ‹¨ν•œ μœ ν‹Έλ¦¬ν‹° λΌμ΄λΈŒλŸ¬λ¦¬μž…λ‹ˆλ‹€.
  4. entry point: (ν•„μˆ˜)
    • νŒ¨ν‚€μ§€κ°€ λͺ¨λ“ˆλ‘œ μ‚¬μš©λ  λ•Œ 싀행될 κΈ°λ³Έ νŒŒμΌμž…λ‹ˆλ‹€. μ‘μš© ν”„λ‘œκ·Έλž¨μ˜ μ§„μž…μ μž…λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: index.js
    • μ˜ˆμ‹œ: main.js, app.js
  5. test command: (선택 사항)
    • npm testλ₯Ό μ‹€ν–‰ν•  λ•Œ npm이 μ‹€ν–‰ν•  λͺ…λ Ήμž…λ‹ˆλ‹€. ν”„λ‘œμ νŠΈμ˜ ν…ŒμŠ€νŠΈλ₯Ό μ‹€ν–‰ν•˜λŠ” 데 μ‚¬μš©λ©λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: (λΉ„μ–΄ 있음)
    • μ˜ˆμ‹œ: jest, mocha
  6. git repository: (선택 사항)
    • ν”„λ‘œμ νŠΈμ˜ Git μ €μž₯μ†Œ URLμž…λ‹ˆλ‹€ (예: https://github.com/yourusername/my-awesome-project). 쒅속성 관리 및 ν˜‘μ—…μ— 도움이 λ©λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: (λΉ„μ–΄ 있음)
    • μ˜ˆμ‹œ: github.com/yourusername/my-awesome-project (Git μ €μž₯μ†Œμ— μžˆλŠ” 경우 npm이 μ’…μ’… 이λ₯Ό μΆ”λ‘ ν•  수 μžˆμŠ΅λ‹ˆλ‹€.)
  7. keywords: (선택 사항)
    • ν”„λ‘œμ νŠΈλ₯Ό μ„€λͺ…ν•˜λŠ” ν‚€μ›Œλ“œ λͺ©λ‘μž…λ‹ˆλ‹€. μ‚¬λžŒλ“€μ΄ npmμ—μ„œ 검색할 λ•Œ νŒ¨ν‚€μ§€λ₯Ό μ°ΎλŠ” 데 도움이 λ©λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: (λΉ„μ–΄ 있음)
    • μ˜ˆμ‹œ: string, utility, manipulation
  8. author: (선택 사항)
    • λ‹Ήμ‹ μ˜ 이름 및/λ˜λŠ” 이메일 μ£Όμ†Œμž…λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: (λΉ„μ–΄ 있음)
    • μ˜ˆμ‹œ: John Doe <john.doe@example.com>
  9. license: (ν•„μˆ˜)
    • ν”„λ‘œμ νŠΈκ°€ λ°°ν¬λ˜λŠ” λΌμ΄μ„ μŠ€μž…λ‹ˆλ‹€ (예: MIT, ISC, GPLv3). λΌμ΄μ„ μŠ€ 선택은 λ²•μ μœΌλ‘œ μ€‘μš”ν•©λ‹ˆλ‹€.
    • κΈ°λ³Έκ°’: ISC
    • μ˜ˆμ‹œ: MIT
  10. About to write to /path/to/your/project/package.json: ...
    • 생성될 package.json νŒŒμΌμ˜ λ‚΄μš©μ„ λ³΄μ—¬μ£ΌλŠ” 확인 λ©”μ‹œμ§€μž…λ‹ˆλ‹€. νŒŒμΌμ„ μž‘μ„±ν•˜κΈ° 전에 정보λ₯Ό κ²€ν† ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
  11. 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:

  1. 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
  2. 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)
  3. 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.
  4. 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
  5. 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
  6. 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)
  7. 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
  8. author: (optional)
    • Your name and/or email address.
    • Default: (blank)
    • Example: John Doe <john.doe@example.com>
  9. 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
  10. About to write to /path/to/your/project/package.json: ...
    • This is a confirmation message showing you the contents of the package.json file that will be created. You can review the information before it’s written to the file.
  11. Is this OK?
    • Type yes or y to confirm and create the package.json file. Type no or n to cancel.

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.

Leave a Reply