npm publish

パッケージと実行環境

書き方

npm publish [--access public] [--tag <tag>]

パッケージをレジストリへ上げます。@scope名は既定で非公開なので--access publicが必要で、一度使ったバージョン番号は二度と使えないため、まず--dry-runで入るファイルを確かめます。

よく使うオプション

オプション意味
--access publicrequired for a scoped package, which is private by default
--tag <tag>publish under a tag such as next, leaving latest alone
--dry-runshow the file list and version without uploading
--otp <code>pass a two-factor code
--provenanceattach a signed build statement from CI

npm publish --dry-run

shows exactly which files would ship

npm publish --access public

publishes @scope/name so anyone can install it

npm publish --tag next

a prerelease that npm install does not pick up

何をどこに入れるかが問題です。このプロジェクトの中か、マシン全体かを先に決めてください。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. npm publish は何をしますか。

パッケージをレジストリへ上げます。@scope名は既定で非公開なので--access publicが必要で、一度使ったバージョン番号は二度と使えないため、まず--dry-runで入るファイルを確かめます。

Q. どう打ちますか。

npm publish [--access public] [--tag <tag>] — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは5個です。全部は man npm にあります。このコマンドはパッケージと実行環境の仲間です。

関連するコマンド

man ページ: man npm-publish