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
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
430
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.2k
A Tour of Anti-patterns for Functional Programming
guvalif
0
730
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
660
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
260
日経電子版のStoreKit2フルリニューアル
shimastripe
1
160
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
580
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
610
SDN の Hype Cycle を一通り経験してみて思うこと / Going through the Hype Cycle of SDN
mshindo
3
250
OCI Vault 概要
oracle4engineer
PRO
0
9.8k
アジャイルチームがらしさを発揮するための目標づくり / Making the goal and enabling the team
kakehashi
4
290
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
130
Featured
See All Featured
Building Adaptive Systems
keathley
38
2.3k
Building Your Own Lightsaber
phodgson
103
6.1k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Side Projects
sachag
452
42k
KATA
mclloyd
29
14k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Thoughts on Productivity
jonyablonski
67
4.3k
A better future with KSS
kneath
238
17k
Git: the NoSQL Database
bkeepers
PRO
427
64k
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 • ʮৄ͘͠ʯ • ʮͱΓ͋͑ͣ༡ͼʹߦͬͯΈ͍ͨʂʯ • ʮԶ͕ೖΒͣ୭͕ೖΔʂʯ ੋඇੋඇʂʂ