[react] package.json

dev stefanCho·2021년 9월 30일
0

react

목록 보기
13/19

package.json에 대한 내용을 정리한다.

main

"main": "dist/index.js"

npm으로 import하는 경우, 진입하는 최초 파일을 지정한다.

types

"types": "dist/index.d.ts"

npm으로 import하는 경우, Type definition 파일을 지정한다.

files

"files": ["dist"]

package를 publish했을 때 npm에 올릴 file directory를 지정함

publishConfig

"publishConfig": { "access": "public" }

package가 public access가능하도록 설정

bin

"name": "test-app",
"bin": "dist/index.js"

터미널에서 바로 실행할 파일 지정
터미널에서 npx로 바로 실행하려면, index.js 첫 줄에 #!/usr/bin/env node를 써주면 됨

ex) test-app이라는 이름의 package를 command line에서 실행할 때 실행되는 파일의 위치이다.

script

"scripts": {
  "prepublishOnly": "tsc"
}

prepublishOnly는 npm의 lifeCycle으로, npm publish를 해줄 때, 미리 실행해주는 것이다. (예시는 tsc(typescript compile)을 먼저 해주는 것이다.)

profile
Front-end Developer

0개의 댓글