![전역 변수를 사용하여 노드 스크립트 실행](https://linux55.com/image/163457/%EC%A0%84%EC%97%AD%20%EB%B3%80%EC%88%98%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EB%85%B8%EB%93%9C%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%20%EC%8B%A4%ED%96%89.png)
index.js
node_modules 폴더가 있는 노드 스크립트가 있습니다.
/script/myTestJscript/index.js
/script/myTestJscript/node_modules
/script/myTestJscript/package.json
다음 명령을 사용하여 스크립트를 실행할 수 있습니다./index.js
mytestscript
예를 들어 콘솔에서 명령을 호출하여 전역 명령을 사용하여 스크립트를 실행하려면 어떻게 해야 합니까 ?
사용해 보았지만 sudo ln -s ./script/myTestJscript/index.js mytestscript
작동하지 않습니다
답변1
index.js 프로그램에 다른 콘텐츠가 필요한 방식에 따라 해당 디렉터리에 있어야 할 수도 있습니다. 나는 함수를 사용할 것이다:
mytestscript() {
cd /path/to/myTestJscript && ./index.js
}
당신은 당신의에 저장할 수 있습니다~/.bashrc