{"componentChunkName":"component---src-templates-blog-post-js","path":"/nodejs/dirname/","result":{"data":{"site":{"siteMetadata":{"title":"Progress Not Perfection","author":"Sunmin","siteUrl":"https://sunmin.netlify.com","comment":{"disqusShortName":"","utterances":"Sunmin0520/blog"}}},"markdownRemark":{"id":"dd5af206-efc2-5618-8299-14c249fab0df","excerpt":"__dirname 파일에 _filename, _dirname을 넣어두면 실행을 할 때의 파일명과 경로로 바뀌어서 나타난다. 즉 절대경로를 알려주는 환경변수. path.join(path) path.join 을 사용해서 인자들끼리 이어준다. path.join(‘/foo’, ‘bar’, ‘baz/asdf’, ‘quux’, ’..’);  //‘/foo/bar/baz/asdf’ path.join(‘foo’, {}, ‘bar’); //Throws ‘TypeError: Path must be a string…","html":"<p>\n<h2 id=\"__dirname\" style=\"position:relative;\"><a href=\"#__dirname\" aria-label=\"__dirname permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>__dirname</h2>\n<ul>\n<li>파일에 _filename, _dirname을 넣어두면 <strong>실행을 할 때의 파일명과 경로로 바뀌어서</strong> 나타난다. 즉 절대경로를 알려주는 환경변수.</li>\n</ul>\n<br>\n<img src=\"https://user-images.githubusercontent.com/60782131/109975077-961ea580-7d3d-11eb-9bb4-57be20a4a92d.png\">\n<h2 id=\"pathjoinpath\" style=\"position:relative;\"><a href=\"#pathjoinpath\" aria-label=\"pathjoinpath permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>path.join([path])</h2>\n<ul>\n<li>\n<p>path.join 을 사용해서 인자들끼리 이어준다.</p>\n<ul>\n<li>path.join(‘/foo’, ‘bar’, ‘baz/asdf’, ‘quux’, ’..’);  //‘/foo/bar/baz/asdf’</li>\n<li>path.join(‘foo’, {}, ‘bar’); //Throws ‘TypeError: Path must be a string. Received {}’</li>\n<li><strong>path.join(__dirname, “/test1”)</strong> 이런 식으로 붙임</li>\n</ul>\n</li>\n</ul>\n<br />\n<p><strong>출처</strong></p>\n<ul>\n<li><a href=\"https://nodejs.org/docs/latest/api/modules.html#modules_dirname\">__dirname</a></li>\n<li><a href=\"https://nodejs.org/api/path.html#path_path_join_paths\">path.join</a></li>\n</ul>\n</p>","frontmatter":{"title":"[Node.js] __dirname, path.join","date":"March 04, 2021"}}},"pageContext":{"slug":"/nodejs/dirname/","previous":{"fields":{"slug":"/CS/absolute_relative_path/"},"frontmatter":{"title":"[CS] 절대경로, 상대경로","category":"cs","draft":false}},"next":{"fields":{"slug":"/JavaScript/getter_setter/"},"frontmatter":{"title":"[JS] 접근자 프로퍼티와 getter, setter","category":"javascript","draft":false}}}},"staticQueryHashes":["3128451518","521680639"]}