npm-init.1 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. .TH "NPM\-INIT" "1" "August 2021" "" ""
  2. .SH "NAME"
  3. \fBnpm-init\fR \- create a package\.json file
  4. .SS Synopsis
  5. .P
  6. .RS 2
  7. .nf
  8. npm init [\-\-force|\-f|\-\-yes|\-y|\-\-scope]
  9. npm init <@scope> (same as `npx <@scope>/create`)
  10. npm init [<@scope>/]<name> (same as `npx [<@scope>/]create\-<name>`)
  11. .fi
  12. .RE
  13. .SS Examples
  14. .P
  15. Create a new React\-based project using \fBcreate\-react\-app\fP \fIhttps://npm\.im/create\-react\-app\fR:
  16. .P
  17. .RS 2
  18. .nf
  19. $ npm init react\-app \./my\-react\-app
  20. .fi
  21. .RE
  22. .P
  23. Create a new \fBesm\fP\-compatible package using \fBcreate\-esm\fP \fIhttps://npm\.im/create\-esm\fR:
  24. .P
  25. .RS 2
  26. .nf
  27. $ mkdir my\-esm\-lib && cd my\-esm\-lib
  28. $ npm init esm \-\-yes
  29. .fi
  30. .RE
  31. .P
  32. Generate a plain old package\.json using legacy init:
  33. .P
  34. .RS 2
  35. .nf
  36. $ mkdir my\-npm\-pkg && cd my\-npm\-pkg
  37. $ git init
  38. $ npm init
  39. .fi
  40. .RE
  41. .P
  42. Generate it without having it ask any questions:
  43. .P
  44. .RS 2
  45. .nf
  46. $ npm init \-y
  47. .fi
  48. .RE
  49. .SS Description
  50. .P
  51. \fBnpm init <initializer>\fP can be used to set up a new or existing npm package\.
  52. .P
  53. \fBinitializer\fP in this case is an npm package named \fBcreate\-<initializer>\fP, which
  54. will be installed by \fBnpx\fP \fIhttps://npm\.im/npx\fR, and then have its main bin
  55. executed \-\- presumably creating or updating \fBpackage\.json\fP and running any other
  56. initialization\-related operations\.
  57. .P
  58. The init command is transformed to a corresponding \fBnpx\fP operation as follows:
  59. .RS 0
  60. .IP \(bu 2
  61. \fBnpm init foo\fP \-> \fBnpx create\-foo\fP
  62. .IP \(bu 2
  63. \fBnpm init @usr/foo\fP \-> \fBnpx @usr/create\-foo\fP
  64. .IP \(bu 2
  65. \fBnpm init @usr\fP \-> \fBnpx @usr/create\fP
  66. .RE
  67. .P
  68. Any additional options will be passed directly to the command, so \fBnpm init foo
  69. \-\-hello\fP will map to \fBnpx create\-foo \-\-hello\fP\|\.
  70. .P
  71. If the initializer is omitted (by just calling \fBnpm init\fP), init will fall back
  72. to legacy init behavior\. It will ask you a bunch of questions, and then write a
  73. package\.json for you\. It will attempt to make reasonable guesses based on
  74. existing fields, dependencies, and options selected\. It is strictly additive, so
  75. it will keep any fields and values that were already set\. You can also use
  76. \fB\-y\fP/\fB\-\-yes\fP to skip the questionnaire altogether\. If you pass \fB\-\-scope\fP, it
  77. will create a scoped package\.
  78. .SS See Also
  79. .RS 0
  80. .IP \(bu 2
  81. https://github\.com/isaacs/init\-package\-json
  82. .IP \(bu 2
  83. npm help package\.json
  84. .IP \(bu 2
  85. npm help version
  86. .IP \(bu 2
  87. npm help scope
  88. .RE