array map function use ts
npm install 03test-array-mappackage.json 配置
``sh
`
package name: (03test-array-map)
version: (1.0.0)
description: array map function use ts
entry point: (index.js) ./dist/test-array-map.js
`
json
`
{
"name": "03test-array-map",
"version": "1.0.0",
"description": "array map function use ts",
// 下載這個包的使用者會到 "./dist/test-array-map.js" 這個路徑下引入文件
"main": "./dist/test-array-map.js"
}
`
初始化 tsconfig.json 配置
終端機輸入
sh
`
tsc --init
`
.npmignore 配置檔
npm 發包的忽略檔案配置, 預設 node_modules 是被忽略的
`
// 忽略 example 資料夾下的所有檔案
/example/
`
終端機輸入指令
sh
`
npm login
`
輸入在 npm 註冊的帳號
npm 帳號要有 email 驗證, 否則會報錯
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy.
登入帳號後, 執行指令將包發布到 NPM 上
sh
`
npm publish
`
sh
``
// 出現下面訊息就代表成功
npm notice
+ 03test-array-map@1.0.0