ããã¯ããªã«ãããããŠæžãããã®ïŒ
npm install
ïŒnpm i
ïŒã§ã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ããæã«ããŒãžã§ã³ãæå®ããããpackage.json
ã«èšèŒããã
ããŒãžã§ã³è¡šèšã«ã€ããŠé°å²æ°ã§ããèŠãŠããªãã£ãã®ã§ãã¡ãããšèŠãŠã¿ããããªãšã
ãªããããã±ãŒãžã®äŸåé¢ä¿ãããæ°ããããŒãžã§ã³ããªãªãŒã¹ãããŠãããã©ããã®ç¢ºèªã«ã¯ããã¡ããã
npmでプロジェクトの依存関係の確認や、依存パッケージのバージョン確認などを行ってみる - CLOVER🍀
ã©ããããšãããæ°ã«ãªã£ãŠããïŒ
^
ã~
ã§ããŒãžã§ã³ã®ç¯å²ãçµã蟌ãã§ããã®ã¯ãŸã ããã®ã§ãããããããã£ãŠããªãã£ãã®ã¯ãããããã®ã§ããã
v[Major Version]
ãæå®ããã
$ npm install redis@v3
next
ãæå®ãããããããã®ããªã©ã§ããã
$ npm install react-router@next
ããã¥ã¡ã³ããèŠã€ã€ãå®éã«ã³ãã³ãã䜿ã£ãŠç¢ºèªããŠãããŸãããã
ç°å¢
ä»åã®ç°å¢ã¯ããã¡ãã
$ npm --version 8.1.2
ããã¥ã¡ã³ããåç §ããéã«ããŒãžã§ã³ãå¿ èŠãªå Žåã¯ãv8ã®ãã®ãèŠãŠãããŸãã
ããã±ãŒãžãšã¢ãžã¥ãŒã«ã«ã€ããŠ
ãŸãã¯ãããã±ãŒãžãšã¢ãžã¥ãŒã«ã«ã€ããŠãããã¥ã¡ã³ãã¯ãã¡ãã
About packages and modules | npm Docs
äž¡è ã¯ãå³å¯ã«ã¯éããã®ãªãã§ããã
ãããã±ãŒãžããšã¯ãpackage.json
ã«ãã£ãŠèšè¿°ããããã¡ã€ã«ããã£ã¬ã¯ããªã®ããšãæããŠããŸãã
About packages and modules / About packages
äžæ¹ã§ãã¢ãžã¥ãŒã«ããšããã®ã¯ãnode_modules
ãã£ã¬ã¯ããªå
ã«ããä»»æã®ãã¡ã€ã«ããã£ã¬ã¯ããªã§ã
Node.jsã®require
é¢æ°ã§ããŒãã§ãããã®ã§ãã
About packages and modules / About modules
npmã§ã€ã³ã¹ããŒã«ããã®ã¯ãããã±ãŒãžãã«ãªããå®éã«ããã°ã©ã ã§å©çšã§ããç¶æ
ã®ãã®ã¯ãã¢ãžã¥ãŒã«ããšåŒã¶ã
ãšãã£ããšããã§ããããã
ããã±ãŒãžã®ãã©ãŒãããã¯ã以äžã®ããããã«ãªããŸãã
- (a)
package.json
ã§èšè¿°ãããããã°ã©ã ãå«ããã£ã¬ã¯ã㪠- (b) (a)ãgzipããtarball
- (c) (b)ã解決ã§ããURL
- (d) (c)ãã¬ãžã¹ããªãŒã§
<name>@<version>
ãšããŠå ¬éãããã® - (e) (d)ã
<name>@<tag>
ã§æãããã® - (f) (e)ãæºãã
latest
ã¿ã°ãæã€<name>
ïŒããã±ãŒãžåïŒ - (g)
git clone
ããæã«(a)ã«ãªããã®
About packages and modules / About package formats
ãµã ãäœæ°ãªããã£ãŠãã以äžã®ã³ãã³ãïŒããŒãžã§ã³æå®ãªãïŒã¯ã(f)ã䜿ã£ãŠããããšã«ãªããŸããã
$ npm install [ããã±ãŒãžå]
ããäžè¶³é£ã³æããããŸãããããã¯åŸã»ã©âŠã
ã¹ã³ãŒã
ããã±ãŒãžã«ã¯ãã¹ã³ãŒããæãããããšãã§ããŸãã
ã¹ã³ãŒããšã¯ãnpmã«ãµã€ã³ã¢ããããããOrganizationãäœæãããšä»äžããããã®ã§ããŠãŒã¶ãŒãŸãã¯Organizationã
åäœã«ãªããŸãã
ã¹ã³ãŒãã䜿ãããšã§ãååã®ããã±ãŒãžã®ç«¶åãé²ãããšãã§ããŸãããšã
æžåŒã¯ä»¥äžã§ãã
@[ã¹ã³ãŒãå]/[ããã±ãŒãžå]
äŸã«ãæžãããŠããŸãããããšãã°npm
ã¹ã³ãŒãã§ããã°ä»¥äžã«ãªããŸãã
@npm/package-name
ã¹ã³ãŒãã¯ãããªãã¯ããã±ãŒãžã§ããã°ã䜿ã£ãŠã䜿ããªããŠãããã¿ããã§ãã
About public packages | npm Docs
ãã©ã€ããŒãããã±ãŒãžã®å Žåã¯ãåžžã«ã¹ã³ãŒãã䜿ãããšã«ãªããŸãã
About private packages | npm Docs
ããŸã«ãnpm install
ããæã«@
ãã€ããŠããããã±ãŒãžã®æå³ãããããŸããâŠã
ããã±ãŒãžã®ããŒãžã§ã³ã€ããŠ
ããã±ãŒãžã®ãã©ãŒãããã§åºãŠããã<version>
ãš<tag>
ã«ã€ããŠèŠãŠãããŸãããã
About semantic versioning | npm Docs
Adding dist-tags to packages | npm Docs
ãŸãã¯ããŒãžã§ã³ãããnpmããã±ãŒãžã¯ãã»ãã³ãã£ãã¯ããŒãžã§ãã³ã°ã«ç¿ãããšãæšå¥šãããŠããŸãã
About semantic versioning | npm Docs
Semantic Versioning 2.0.0 | Semantic Versioning
ã»ãã³ãã£ãã¯ããŒãžã§ãã³ã°ã¯ãã¡ãžã£ãŒããã€ããŒããããã®3ã€ã®ããŒãžã§ã³ãè¡šãæ°åã§æ§æãããããã§ããã
npmã§ã¯ããã±ãŒãžã®æŽæ°ç¯å²ãæå®ã§ããŸãã
ããã¥ã¡ã³ãã«ç¿ã£ãŠ1.0.4ãäŸã«ãããšããããªæãã«ãªããŸãã
- ããããªãªãŒã¹ã®æŽæ°ç¯å²ã«çãããå Žå âŠ
1.0
ã1.0.x
ã~1.0.4
- ãã€ããŒãªãªãŒã¹ã®æŽæ°ç¯å²ã«çãããå Žå âŠ
1
ã1.x
ã^1.0.4
- ã¡ãžã£ãŒãªãªãŒã¹ïŒèŠããã«ææ°ïŒ âŠ
*
ãx
ããšãã°ããªã«ãèããã«Expressãã€ã³ã¹ããŒã«ãããš
$ npm i express
çŸæç¹ã§ã¯ä»¥äžã®ãããªè¡šèšã«ãªããŸãããããã¯Express 4.17.2ããæ°ãã4.xç³»ã§æŽæ°ç¯å²ãæå®ããŠããããšã«
ãªããŸãã
"dependencies": { "express": "^4.17.2" }
å®éã«äœ¿ãããããã±ãŒãžãšãéžæãããããŒãžã§ã³ã®ç¯å²ã確èªãããå Žåã¯ã以äžã®ãµã€ãã䜿ããšããã§ãããã
npm semantic version calculator
æå®ããããã±ãŒãžã®ããŒãžã§ã³ãäžèŠ§è¡šç€ºãããæå®ããããŒãžã§ã³ãã¿ãŒã³ã«ãããããããŒãžã§ã³ããã€ã©ã€ã
ãããã®ã§ãèšè¿°æ¹æ³ã®ç¢ºèªã«ãªããŸãã
"v"ã«ã€ããŠ
ããŸã«ãnpm install
æã«ããŒãžã§ã³ã«v
ãä»ããŠæå®ããŠããäŸãèŠãããšããããŸãã
ããã¯ã©ãæãããããã®ã§ããããïŒ
npmã®ããã¥ã¡ã³ãã«ã¯ç¹ã«èšè¿°ããªãããã§ãããã»ãã³ãã£ãã¯ããŒãžã§ãã³ã°ã®æ¹ãèŠããšãªããšãªã
ãããããã§ãã
Semantic Versioning 2.0.0 / Is âv1.2.3â a semantic version?
ããšãã°ãv1.2.3
ã¯ã»ãã³ãã£ãã¯ããŒãžã§ãã³ã°ã§ã¯ãããŸããããã ãã»ãã³ãã£ãã¯ããŒãžã§ãã³ã°ã®åã«
v
ãä»ããããšã¯ããŒãžã§ã³çªå·ã瀺ãäžè¬çãªæ¹æ³ãšãªã£ãŠããŸãã
v1.2.3
ã¯ã¿ã°ã§ã1.2.3
ãã»ãã³ãã£ãã¯ããŒãžã§ã³ãã³ã°ãšãªããŸãã
ãšãªããšã以äžã®ãããªäŸã¯v
ãèªã¿é£ã°ãã°è¯ãããã§ããïŒã¡ãžã£ãŒããŒãžã§ã³3.xã®ç¯å²ã§ããã±ãŒãžã
ã€ã³ã¹ããŒã«ããïŒã
$ npm install redis@v3
ãªããšãªãæå³ã¯ãããã®ã§ãããæ å ±ãè¿œããšãããªãšããã§ããããã
ããã±ãŒãžã®ã¿ã°ã«ã€ããŠ
ç¶ããŠãã¿ã°ã«ã€ããŠã
Adding dist-tags to packages | npm Docs
ã¿ã°ã¯ã»ãã³ãã£ãã¯ããŒãžã§ã³ã«å¯ŸããŠã人éãèªãã圢åŒã®ã©ãã«ãä»äžãããã®ã§ãã
ãšããã§ããã®ããã¥ã¡ã³ãã«ã¯latest
ãªã©ã«ã€ããŠã¯æžãããŠããŸãããããã¯ãnpm dist-tag
ã³ãã³ãã®
ããã¥ã¡ã³ãã«æžãããŠããŸãã
latestã¿ã°ãnextã¿ã°
ã¿ã°ã«ã€ããŠãããå°ãè¿œã£ãŠã¿ãŸãã
npm dist-tag
ã³ãã³ãã®ããã¥ã¡ã³ããèŠããšãlatest
ãšnext
ã«é¢ããå
容ãããå°ãæžããŠãããŸãã
latest
ã¿ã°ã¯ãããã±ãŒãžãå
¬éããæã«--tag
ãªãã·ã§ã³ã䜿ãããŠããªãéãããã®ããŒãžã§ã³ãlatest
ã¿ã°ãšããŠ
èšå®ãããŸãã
Publishing a package sets the latest tag to the published version unless the --tag option is used.
ãããŠãããã±ãŒãžãã€ã³ã¹ããŒã«ããéã«@<version>
ãŸãã¯@<tag>
ãæå®ããŠããªãå Žåãããã©ã«ãã§
latest
ã¿ã°ã®ããã±ãŒãžãã€ã³ã¹ããŒã«ããæ¯ãèããããŸãã
By default, npm install
(without any @ or @ specifier) installs the latest tag. By default, the latest tag is used by npm to identify the current version of a package, and npm install
(without any @ or @ specifier) installs the latest tag.
ããããnpm install
ã§ããã±ãŒãžåã®ã¿ãæå®ããå Žåã«(f)ïŒlatest
ã¿ã°ïŒãæå®ãããããšãšåãã«ãªãã
ãšããçç±ã§ããã
éåžžãlatest
ã¯å®å®ãããªãªãŒã¹ããŒãžã§ã³ã«ã®ã¿äœ¿çšãããªãªãŒã¹åã®å®å®ããŠããªãããŒãžã§ã³ãªã©ã«ã¯
ä»ã®ã¿ã°ã䜿çšããŸãã
Typically, projects only use the latest tag for stable release versions, and use other tags for unstable versions such as prereleases.
latest
ãé€ããŠãnpmã«ã¯ç¹å¥ãªæå³ãæã€ã¿ã°ã¯ãããŸããã
Other than latest, no tag has any special significance to npm itself.
next
ã¿ã°ã«ã€ããŠã¯ã次ã®ããŒãžã§ã³ãèå¥ããããã«äžéšã®ãããžã§ã¯ãã䜿çšããŠããããšãããããšãã£ã
äœçœ®ã¥ãïŒæ
£äŸïŒïŒã¿ããã§ããã
The next tag is used by some projects to identify the upcoming version.
ä»ã®äŸãšããŠã¯ãstable
ãbeta
ãdev
ãcanary
ãªã©ãæããããããã§ãã
For example, a project might choose to have multiple streams of development and use a different tag for each stream, e.g., stable, beta, dev, canary.
ãããŸã§ã§ããããããŒãžã§ã³ãšã¿ã°ã¯ããã£ãæ°ãããŸãã
npm view
ããããå ã¯ãå°ãnpmã³ãã³ããèŠãŠãããŸãããã
ãŸãã¯npm view
ããã
view
ã®ä»£ããã«ããšã€ãªã¢ã¹ãšããŠinfo
ãshow
ãv
ãå©çšã§ããŸãã
Expressã§è©ŠããŠã¿ãŸãããã
$ npm view express express@4.17.2 | MIT | deps: 30 | versions: 265 Fast, unopinionated, minimalist web framework http://expressjs.com/ keywords: express, framework, sinatra, web, http, rest, restful, router, app, api dist .tarball: https://registry.npmjs.org/express/-/express-4.17.2.tgz .shasum: c18369f265297319beed4e5558753cc8c1364cb3 .integrity: sha512-oxlxJxcQlYwqPWKVJJtvQiwHgosH/LrLSPA+H4UxpyvSS6jC5aH+5MoHFM+KABgTOt0APue4w66Ha8jCUo9QGg== .unpackedSize: 209.6 kB dependencies: accepts: ~1.3.7 content-type: ~1.0.4 depd: ~1.1.2 finalhandler: ~1.1.2 on-finished: ~2.3.0 qs: 6.9.6 array-flatten: 1.1.1 cookie-signature: 1.0.6 encodeurl: ~1.0.2 fresh: 0.5.2 parseurl: ~1.3.3 range-parser: ~1.2.1 body-parser: 1.19.1 cookie: 0.4.1 escape-html: ~1.0.3 merge-descriptors: 1.0.1 path-to-regexp: 0.1.7 safe-buffer: 5.2.1 content-disposition: 0.5.4 debug: 2.6.9 etag: ~1.8.1 methods: ~1.1.2 proxy-addr: ~2.0.7 send: 0.17.2 (...and 6 more.) maintainers: - mikeal <mikeal.rogers@gmail.com> - dougwilson <doug@somethingdoug.com> - jasnell <jasnell@gmail.com> dist-tags: latest: 4.17.2 next: 5.0.0-alpha.8 published 2 weeks ago by dougwilson <doug@somethingdoug.com>
ããã±ãŒãžã®æ å ±ã衚瀺ãããŸãã
latest
ã¿ã°ã¯4.17.2
ãnext
ã¿ã°ãèšå®ãããŠããŠ5.0.0-alpha.8
ã§ããããšãããããŸãã
ãã®èšè¿°ã¯ã以äžãšå矩ã§ãã
$ npm view express@latest
next
ã¿ã°ã䜿çšãããšãéçºäžã®5ç³»ã®æ
å ±ã衚瀺ãããŸãã
$ npm view express@next express@5.0.0-alpha.8 | MIT | deps: 31 | versions: 265 Fast, unopinionated, minimalist web framework http://expressjs.com/ ãçç¥ã
ããã±ãŒãžã«ã©ããªããŒãžã§ã³ããããã¯ãnpm view [ããã±ãŒãžå] versions
ã§ç¢ºèªããããšãã§ããŸãã
$ npm view express versions [ '0.14.0', '0.14.1', '1.0.0-beta', '1.0.0-beta2', '1.0.0-rc', '1.0.0-rc2', '1.0.0-rc3', '1.0.0-rc4', '1.0.0', '1.0.1', '1.0.2', '1.0.3', '1.0.4', '1.0.5', '1.0.6', '1.0.7', '1.0.8', '2.0.0-beta', '2.0.0-beta2', '2.0.0-beta3', '2.0.0-rc', '2.0.0-rc2', '2.0.0-rc3', '2.0.0', '2.1.0', '2.1.1', '2.2.0', '2.2.1', ãçç¥ã '4.8.7', '4.8.8', '4.9.0', '4.9.1', '4.9.2', '4.9.3', '4.9.4', '4.9.5', '4.9.6', '4.9.7', '4.9.8', '4.10.0', '4.10.1', '4.10.2', '4.10.3', '4.10.4', '4.10.5', '4.10.6', '4.10.7', '4.10.8', '4.11.0', '4.11.1', '4.11.2', '4.12.0', '4.12.1', '4.12.2', '4.12.3', '4.12.4', '4.13.0', '4.13.1', '4.13.2', '4.13.3', '4.13.4', '4.14.0', '4.14.1', '4.15.0', '4.15.1', '4.15.2', '4.15.3', '4.15.4', '4.15.5', '4.16.0', '4.16.1', '4.16.2', '4.16.3', '4.16.4', '4.17.0', '4.17.1', '4.17.2', '5.0.0-alpha.1', '5.0.0-alpha.2', '5.0.0-alpha.3', '5.0.0-alpha.4', '5.0.0-alpha.5', '5.0.0-alpha.6', '5.0.0-alpha.7', '5.0.0-alpha.8' ]
ãŸããããŒãžã§ã³ã®ç¯å²è¡šèšãšçµã¿åãããããšã§ããã¡ãã®ãµã€ããšè¿ã確èªãè¡ããŸãã
ããã€ãã確èªããŠã¿ãŸããããããŒãžã§ã³ãŸãã¯ããŒãžã§ã³ã®ç¯å²ãæå®ããå Žåãnpm view [ããã±ãŒãžå] version
ãšãªãããšã«æ³šæã§ãïŒversions
ã§ã¯ãªããversion
ïŒã
$ npm view express@4 version express@4.0.0 '4.0.0' express@4.1.0 '4.1.0' express@4.1.1 '4.1.1' express@4.1.2 '4.1.2' express@4.2.0 '4.2.0' express@4.3.0 '4.3.0' express@4.3.1 '4.3.1' express@4.3.2 '4.3.2' express@4.4.0 '4.4.0' express@4.4.1 '4.4.1' express@4.4.2 '4.4.2' express@4.4.3 '4.4.3' express@4.4.4 '4.4.4' ãçç¥ã express@4.15.0 '4.15.0' express@4.15.1 '4.15.1' express@4.15.2 '4.15.2' express@4.15.3 '4.15.3' express@4.15.4 '4.15.4' express@4.15.5 '4.15.5' express@4.16.0 '4.16.0' express@4.16.1 '4.16.1' express@4.16.2 '4.16.2' express@4.16.3 '4.16.3' express@4.16.4 '4.16.4' express@4.17.0 '4.17.0' express@4.17.1 '4.17.1'
ãã¡ãã§ãåãçµæã«ãªããŸãã
$ npm view express@v4 version
ãããããŒãžã§ã³ã®ç¯å²æå®ã
$ npm view express@~4.15.0 version express@4.15.0 '4.15.0' express@4.15.1 '4.15.1' express@4.15.2 '4.15.2' express@4.15.3 '4.15.3' express@4.15.4 '4.15.4' express@4.15.5 '4.15.5'
ãã€ããŒããŒãžã§ã³ã®ç¯å²æå®ã
$ npm view express@^4.15.0 version express@4.15.0 '4.15.0' express@4.15.1 '4.15.1' express@4.15.2 '4.15.2' express@4.15.3 '4.15.3' express@4.15.4 '4.15.4' express@4.15.5 '4.15.5' express@4.16.0 '4.16.0' express@4.16.1 '4.16.1' express@4.16.2 '4.16.2' express@4.16.3 '4.16.3' express@4.16.4 '4.16.4' express@4.17.0 '4.17.0' express@4.17.1 '4.17.1' express@4.17.2 '4.17.2'
ãã³ãã€ã³ãã§ãæå®ã§ããŸãã
$ npm view express@4.17.1 version 4.17.1 $ npm view express version 4.17.2 $ npm view express@latest version 4.17.2 $ npm view express@next version 5.0.0-alpha.8
npm search
æåŸã«ãè足çã«npm search
ãæžããŠãããŸãã
npm search
ã䜿ãããšã§ãããã±ãŒãžã®æ€çŽ¢ãã§ããŸãã
ãã¡ãã§ã®æ€çŽ¢ãšåãã§ããã
express
ã§ã®ç¢ºèªäŸã
$ npm search express NAME | DESCRIPTION | AUTHOR | DATE | VERSION | KEYWORDS express | Fast,⊠| =mikeal⊠| 2021-12-17 | 4.17.2 | express framework sinatra web http rest restful router app api cors | Node.js CORS⊠| =dougwilson⊠| 2018-11-04 | 2.8.5 | cors express connect middleware express-jwt | JWT authentication⊠| =woloski⊠| 2021-08-11 | 6.1.0 | auth authn authentication authz authorization http jwt token oauth express express-handlebars | A Handlebars view⊠| =ericf =sahat⊠| 2021-11-25 | 6.0.2 | express express3 handlebars view layout partials templates is-regex | Is this value a JS⊠| =ljharb | 2021-08-06 | 1.1.4 | regex regexp is regular expression regular expression express-fileupload | Simple express file⊠| =richardgirges⊠| 2021-01-11 | 1.2.1 | express file-upload upload forms multipart files busboy middleware express-http-proxy | http proxy⊠| =villadora⊠| 2021-10-26 | 1.6.3 | express-http-proxy connect-mongo | MongoDB session⊠| =jdesboeufs⊠| 2021-09-17 | 4.6.0 | connect mongo mongodb session express http-proxy-middleware | The one-liner⊠| =chimurai | 2021-07-01 | 2.0.1 | reverse proxy middleware http https connect express fastify polka browser-sync gulp g express-validator | Express middleware⊠| =ctavan⊠| 2021-12-11 | 6.14.0 | express validator validation validate sanitize sanitization xss path-to-regexp | Express style path⊠| =blakeembrey⊠| 2020-09-29 | 6.2.0 | express regexp route routing morgan | HTTP request logger⊠| =dougwilson | 2020-03-20 | 1.10.0 | express http logger middleware mathjs | Math.js is an⊠| =josdejong | 2021-12-29 | 10.0.2 | math mathematics functions numeric algebra parser expression number bignumber complex multer | Middleware for⊠| =hacksparrow⊠| 2021-12-07 | 1.4.4 | form post multipart form-data formdata express middleware helmet | help secure⊠| =adam_baldwin⊠| 2021-05-02 | 4.6.0 | express security headers passport | Simple, unobtrusive⊠| =jaredhanson | 2021-12-16 | 0.5.2 | express connect auth authn authentication express-unless | Conditionally add a⊠| =jfromaniello | 2021-08-03 | 1.0.0 | webpack-hot-middleware | Webpack hot⊠| =glenjamin⊠| 2021-09-14 | 2.25.1 | webpack hmr hot module reloading hot-reloading middleware express serve-favicon | favicon serving⊠| =dougwilson | 2018-03-29 | 2.5.0 | express favicon middleware ignore | Ignore is a manager⊠| =kael | 2021-12-19 | 5.2.0 | ignore .gitignore gitignore npmignore rules manager filter regexp regex fnmatch glob
ãŸãšã
npmã䜿ãæã«æå®ããããŒãžã§ã³ã«ã€ããŠãã¡ãã£ãšèª¿ã¹ãŠã¿ãŸããã
ãªããšãªãé°å²æ°ã§äœ¿ã£ãŠããããšãå€ãã£ãã®ã§ã1床ãã£ããèŠãŠãããŠè¯ãã£ãããªãšæããŸãã
ä»åŸã¯ããã®ããããæèããŠäœ¿ã£ãŠãããŸãããã