---
type: snippet
tags: ['package', 'shell', 'npm', 'node']
status: release
ctime: 2022-10-12
mtime: 2024-03-22
---

```json
// 현재 실행된 stage 값을 참조하기
// 하지만 스크립트를 따로 작성하는게 더 효율적으로 보인다.

{
  "scripts": {
    "dev:hello": "echo ${npm_lifecycle_event//dev:/}"
  }
}
```

---

- [yarnpkg - Is there a way to get the name of the npm script passed to the command specified by that script? - Stack Overflow](https://stackoverflow.com/questions/62865856/is-there-a-way-to-get-the-name-of-the-npm-script-passed-to-the-command-specified)[^213-1]
- [scripts | npm Docs](https://docs.npmjs.com/cli/v8/using-npm/scripts)[^213-2]

---

[^213-1]: npm 스크립트의 이름을 얻는 방법에 대한 질문과 `npm_lifecycle_event` 환경 변수를 사용하는 방법으로 제안
[^213-2]: package.json 파일에서 스크립트를 사용하는 방법에 대한 개요, 기본 제공 환경 변수 목록도 포함
