Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
hello npm
Search
Muyuu Fujita
May 14, 2016
Technology
0
1.2k
hello npm
初夏のJavaScript祭で発表したスライドです
Muyuu Fujita
May 14, 2016
Tweet
Share
Other Decks in Technology
See All in Technology
React Routerで実現する型安全なSPAルーティング
sansantech
PRO
2
350
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
170
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
200
TypeScript開発にモジュラーモノリスを持ち込む
sansantech
PRO
3
780
プロダクト組織で取り組むアドベントカレンダー/Advent Calendar in Product Teams
mixplace
0
550
Unlearn Product Development - Unleashed Edition
lemiorhan
PRO
2
150
Qiita埋め込み用スライド
naoki_0531
0
5.4k
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
130
20241218_マルチアカウント環境におけるIAM_Access_Analyzerによる権限管理.pdf
nrinetcom
PRO
3
130
ガバナンスを支える新サービス / New Services to Support Governance
sejima1105
1
640
【令和最新版】ロボットシミュレータ Genesis x ROS 2で始める快適AIロボット開発
hakuturu583
2
1.1k
Web APIをなぜつくるのか
mikanichinose
0
1k
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
The Language of Interfaces
destraynor
155
24k
YesSQL, Process and Tooling at Scale
rocio
170
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.2k
Typedesign – Prime Four
hannesfritz
40
2.4k
Music & Morning Musume
bryan
46
6.2k
Embracing the Ebb and Flow
colly
84
4.5k
Agile that works and the tools we love
rasmusluckow
328
21k
The Invisible Side of Design
smashingmag
299
50k
Optimising Largest Contentful Paint
csswizardry
33
3k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Fireside Chat
paigeccino
34
3.1k
Transcript
hello npm!
ࣗݾհ me = { name: "muyuu", twitter: "@anticyborg", belongs: "freelance",
job: "Web Front-End Engineer" };
ओͳࣄ • WebαʔϏεӡ༻ͷϑϩϯτ୲ • খنͷWebϖʔδ/LP੍࡞
ओͳࣄ • WebαʔϏεӡ༻ͷϑϩϯτ୲ • খنͷWebϖʔδ/LP੍࡞ ࠓճͬͪ͜ͷ
Α͘ࢥ͏͜ͱ • ੍࡞ظ͕͍ؒҊ͕݅ଟ͍ • htmlcssjsಉ͡Α͏ͳهड़͕ଟ͍ • JSͰͷUI࣮େମࣗ࡞ͷͷʹͳΔ • ϥΠϒϥϦͷղੳɾΧελϜʹ͔͚Δ࣌ؒͰ࡞ΕΔ
Α͘Δ࡞ۀ • ҎલͷҊ݅Ͱॻ͍ͨUIͷϦιʔεΛ͍͍ͨ • ֘Ҋ݅ϑΥϧμ͔Β֘ϑΝΠϧΛ୳͢ • ֘ՕॴΛҊ݅ʹίοϖ
Ͳ͏ʹ͔ ͳΒΜͷ͔
ͦ͏ͩ ϞδϡʔϧԽͩ
Ϟδϡʔϧ • ύʔπͷͻͱ·ͱ·ΓΛϞδϡʔϧͱͯ͠ߟ͑ɺϑΝΠϧΛ ׂ͍ͯ͘͠ • ࡞ͬͨϞδϡʔϧΛ͔Γ͘͢ɺ͍ճ͍͢͠Α͏ʹ ஔ͢Δ
Ϟδϡʔϧ project_root └ htdocs/ └ src/ └ html/ (index.jadeͱ͔ॾʑ) └
css/ (style.sassͱ͔ॾʑ) └ js/ (main.jsͱ͔ॾʑ) └ modules/ └ tab/ _tab.sass tab.js
Ϟδϡʔϧ • σΟϨΫτϦຖίοϖͰ͢Ή • srcʹஔ͢ΔͳΒʮ͍ͭ͏ηοτʯʹͯ͠ྑ͍
…੯͍͠
…݁ہίοϖɻ
ͦ͜Ͱ npmͩ
what is npm?
what is npm? • JavaScriptͷύοέʔδϚωʔδϟʔ • ੈքதͷσϕϩούʔ͕࡞ͬͨύοέʔδΛ͑Δ • ύοέʔδͷґଘؔɺόʔδϣϯͷཧ •
ݩʑNodeJSͰͷ༻͕ϝΠϯͩͬͨ • ͕ࣗ࡞ͬͨύοέʔδΛެ։͢Δ͜ͱͰ͖Δ
ඞཁͳͷͱྲྀΕ • npmΞΧϯτΛ࡞ • ύοέʔδ໊ΛܾΊΔ • ࣮͢Δ • ࣮Λஔ͍ͨGithubʢ͡Όͳ͍͍͚ͯ͘ͲʣϦϙδτϦ •
package.jsonΛ༻ҙͯ͠npmͷྲّྀʹ߹ΘͤΔ
npmΞΧϯτΛ࡞ • npmͷެࣜϖʔδ͔ΒαΠϯΞοϓ • https://www.npmjs.com/signup
npmΞΧϯτΛ࡞ • λʔϛφϧͰnpm adduserΛ࣮ߦ • username, passwod, emailaddressΛฉ͔ΕΔ͔Β͑Δ
໊લΛܾΊΔ • ͢Ͱʹnpmʹొ͞Ε͍ͯΔ໊લ͚ͭΒΕͳ͍ • ໊લ͕URLʹؚ·ΕΔ • https://www.npmjs.com/package/${name}
࣮͢Δ • ී௨ʹgulpϏϧυͨ͠ΓόϕͬͨΓ͢Δͱ͍͍ • common.jsελΠϧͰॻ͘ͱ৭ʑָͰ͖͓ͯ͢͢Ί • githubͰϗεςΟϯά
npmͷྲّྀʹ߹ΘͤΔ package.jsonʹඞཁࣄ߲هೖ { "name": "Ϟδʔϧ໊", "version": "1.0.0", "description": "֓ཁจ", "author":
"࡞ऀ໊", "license": "ϥΠηϯεܗࣜ", "main": "ϞδϡʔϧຊମϑΝΠϧ", "repository": {"type": "ϦϙδτϦ","url": "ϦϙδτϦURL"} }
npmͷྲّྀʹ߹ΘͤΔ package.jsonʹඞཁࣄ߲هೖ { "scripts": {"εΫϦϓτ໊": "ίϚϯυ"} "dependencies": "͜ͷύοέʔδ͕ґଘ͢ΔϞδϡʔϧ", "devDependencies": "͜ͷύοέʔδ͕։ൃ࣌ʹͷΈґଘ͢ΔϞδϡʔϧ",
}
npmͷྲّྀʹ߹ΘͤΔ package.jsonʹඞཁࣄ߲هೖ { "files": ["npmʹެ։͍ͨ͠ϑΝΠϧɾσΟϨΫτϦ"] } ϒϥοΫϦετํࣜʹ͍ͨ͠߹ϧʔτσΟϨΫτϦ ʹ .npmignore Λ༻ҙ
ެ։
npm publish!
Ξοϓσʔτ • ࣮(͡Όͳ͍͜ͱ͋ΔͩΖ͏͚Ͳ)Λߋ৽͢Δ • όʔδϣϯΛมߋ͢Δ • ϦϙδτϦʹpush • npm publish!
όʔδϣϯͬͯ Ͳ͏͍͏ج४Ͱ Ͳ͏ม͑Ε͍͍ͷʁ
όʔδϣϯΛܾΊΔ • ηϚϯςΟοΫόʔδϣχϯά • http://semver.org/lang/ja/
όʔδϣϯΛܾΊΔ • 1.1.1 • (ϝδϟʔ).(ϚΠφʔ).(ύον) • ޙํޓੑͷͳ͍มߋΛؚΉ߹ϝδϟʔόʔδϣϯ • ޙํޓੑ͕͋ΓػೳՃΛؚΉ߹ϚΠφʔόʔδϣϯ •
ޙํޓੑ͕͋Γόάमਖ਼ͷ߹ύονόʔδϣϯ
npm publish!
ެ։ͨ͠ ύοέʔδΛ ͏
ެ։ͨ͠ύοέʔδΛ͏(scriptλά) • npm install packagename -D htmlʹεΫϦϓτλάهड़ <script src="/node_modules/pkg/pkg.js"></script> <script
src="/assets/js/app.js"></script>
ެ։ͨ͠ύοέʔδΛ͏(concat) • npm install packagename -D • gulpfile.jsͰconcat͢ΔϑΝΠϧʹؚΊΔ gulp.task("concat", =>{
gulp.src([ 'node_modules/pkg/pkg.js', 'src/js/main.js' ]) .pipe(concat('app.js')) .pipe(gulp.dest('./htddocs/')); });
ެ։ͨ͠ύοέʔδΛ͏(browseiry) • npm install packagename -D • main.jsͰrequire͢Δ var pkg
= require('pakegename'); pkg();
࠷ޙʹগ͠ • WebαʔϏεӡ༻ͷϑϩϯτ୲ • খنͷWebϖʔδ/LP੍࡞ ͪΐͬͱͬͪ͜ͷ
࠷ޙʹগ͠ • WebαʔϏεӡ༻ͷϑϩϯτ୲ • খنͷWebϖʔδ/LP੍࡞ ͪΐͬͱͬͪ͜ͷ
גࣜձࣾSpeee σβΠφʔɾϑϩϯτΤϯυΤϯδχΞΛืूͯ͠·͢
גࣜձࣾSpeee • ͓͠ΌΕϥϯδ͕͋Δ • SplatoonΠϕϯτͬͯΔ • ΦϥΠϦʔશ͋Δ • ΤϯδχΞυϦϒϯͳײ͡ •
Ϟμϯ։ൃڥ • RailsϝΠϯͷձࣾ(RubyͷύύʢMatzʣ͕ٕज़ސ)
גࣜձࣾSpeee • ʮৄ͘͠ʯ • ʮͱΓ͋͑ͣ༡ͼʹߦͬͯΈ͍ͨʂʯ • ʮԶ͕ೖΒͣ୭͕ೖΔʂʯ
גࣜձࣾSpeee • ʮৄ͘͠ʯ • ʮͱΓ͋͑ͣ༡ͼʹߦͬͯΈ͍ͨʂʯ • ʮԶ͕ೖΒͣ୭͕ೖΔʂʯ ੋඇੋඇʂʂ