{"id":297670,"date":"2024-05-20T16:33:36","date_gmt":"2024-05-20T08:33:36","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/297670.html"},"modified":"2024-05-20T16:33:48","modified_gmt":"2024-05-20T08:33:48","slug":"webstorm-%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e6%94%af%e6%8c%81-nodejs","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/297670.html","title":{"rendered":"webstorm \u5982\u4f55\u914d\u7f6e\u652f\u6301 nodejs"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27145455\/1a685dc9-faf5-456d-958b-fb4a812b53d1.webp\" alt=\"webstorm \u5982\u4f55\u914d\u7f6e\u652f\u6301 nodejs\" \/><\/p>\n<p><p>WebStorm \u662f\u4e00\u4e2a\u5f3a\u5927\u7684IDE\uff0c\u4e13\u95e8\u7528\u4e8e\u73b0\u4ee3JavaScript\u5f00\u53d1\uff0c\u652f\u6301Node.js\u9879\u76ee\u7684\u521b\u5efa\u548c\u7ba1\u7406\u3002\u914d\u7f6eWebStorm\u4ee5\u652f\u6301Node.js\u9700\u8981\u51e0\u4e2a\u6b65\u9aa4\uff0c<strong>\u8fd9\u5305\u62ec\u5b89\u88c5Node.js\u3001\u914d\u7f6eNode.js\u89e3\u91ca\u5668\u3001\u8bbe\u7f6eNode.js\u9879\u76ee\u7ed3\u6784\u3001\u4ee5\u53ca\u5b89\u88c5\u76f8\u5e94\u7684npm\u5305<\/strong>\u3002<strong>\u5177\u4f53\u7684\u914d\u7f6eNode.js\u89e3\u91ca\u5668\u975e\u5e38\u5173\u952e<\/strong>\uff0c\u56e0\u4e3a\u5b83\u8ba9WebStorm\u80fd\u8bc6\u522bNode.js\u73af\u5883\uff0c\u5e76\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u3001\u8fd0\u884c\u548c\u8c03\u8bd5\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5NODE.JS<\/h3>\n<\/p>\n<p><p>\u5728\u914d\u7f6eWebStorm\u652f\u6301Node.js\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u786e\u4fddNode.js\u5df2\u7ecf\u88ab\u5b89\u88c5\u5728\u4f60\u7684\u7cfb\u7edf\u4e0a\u3002<\/p>\n<\/p>\n<ol>\n<li>\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Node.js\u3002\u8bbf\u95eeNode.js\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/nodejs.org\/%EF%BC%89%E5%B9%B6%E6%A0%B9%E6%8D%AE%E4%BD%A0%E7%9A%84%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E4%B8%8B%E8%BD%BD%E7%9B%B8%E5%BA%94%E7%89%88%E6%9C%AC%E7%9A%84%E5%AE%89%E8%A3%85%E7%A8%8B%E5%BA%8F%E3%80%82\">https:\/\/nodejs.org\/\uff09\u5e76\u6839\u636e\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u8f7d\u76f8\u5e94\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002<\/a><\/li>\n<li>\u6309\u7167\u5b89\u88c5\u5411\u5bfc\u8fdb\u884c\u5b89\u88c5\uff0c\u8fd9\u5c06\u4f1a\u5b89\u88c5Node.js\u8fd0\u884c\u65f6\u4ee5\u53canpm\u5305\u7ba1\u7406\u5668\u3002<\/li>\n<li>\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>node -v<\/code>\u4ee5\u53ca<code>npm -v<\/code>\u3002\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u5c06\u4f1a\u663e\u793aNode.js\u548cnpm\u7684\u7248\u672c\u53f7\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u914d\u7f6eNODE.JS\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p>\u4e00\u65e6\u5b89\u88c5\u4e86Node.js\uff0c\u4f60\u9700\u8981\u5728WebStorm\u4e2d\u914d\u7f6eNode.js\u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\u5728WebStorm\u4e2d\uff0c\u6253\u5f00<strong>File &gt; Settings<\/strong>\uff08\u5bf9\u4e8emacOS\u7684\u7528\u6237\u662f<strong>WebStorm &gt; Preferences<\/strong>\uff09\u3002<\/li>\n<li>\u5728\u5de6\u4fa7\u83dc\u5355\u5185\uff0c\u9009\u62e9<strong>Languages &amp; Frameworks &gt; Node.js and NPM<\/strong>\u3002<\/li>\n<li>\u5728\u53f3\u4fa7\u7684<strong>Node.js Interpreter<\/strong>\u90e8\u5206\uff0c\u70b9\u51fb&#8230;&quot;\u6309\u94ae\u5e76\u4ece\u5df2\u5b89\u88c5\u7684Node.js\u89e3\u91ca\u5668\u4e2d\u9009\u62e9\u4e00\u4e2a\uff0c\u6216\u8005\u70b9\u51fbAdd&#8230;\u6765\u5b9a\u4f4dNode.js\u7684\u5b89\u88c5\u76ee\u5f55\u3002<\/li>\n<li>\u9009\u62e9\u6b63\u786e\u7684Node.js\u89e3\u91ca\u5668\u540e\uff0c\u70b9\u51fb<strong>OK<\/strong>\u6216\u8005<strong>Apply<\/strong>\u6765\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u8bbe\u7f6eNODE.JS\u9879\u76ee\u7ed3\u6784<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u7684\u7ba1\u7406Node.js\u9879\u76ee\uff0c\u4f60\u9700\u8981\u6b63\u786e\u5730\u8bbe\u7f6e\u9879\u76ee\u7ed3\u6784\u3002<\/p>\n<\/p>\n<ol>\n<li>\u65b0\u5efa\u4e00\u4e2aNode.js\u9879\u76ee\uff1a\u5728WebStorm\u7684\u8d77\u59cb\u9875\u4e0a\u9009\u62e9<strong>Create New Project<\/strong>\uff0c\u7136\u540e\u9009\u62e9<strong>Node.js<\/strong>\u5e76\u6307\u5b9a\u9879\u76ee\u4f4d\u7f6e\u3002<\/li>\n<li>WebStorm\u4f1a\u81ea\u52a8\u4e3a\u65b0\u9879\u76ee\u521b\u5efa\u5fc5\u8981\u7684\u6587\u4ef6\u7ed3\u6784\uff0c\u4f8b\u5982<code>package.json<\/code>\u6587\u4ef6\uff0c\u8fd9\u662fNode.js\u9879\u76ee\u7684\u914d\u7f6e\u4e2d\u5fc3\u3002<\/li>\n<li>\u68c0\u67e5\u5e76\u7f16\u8f91<code>package.json<\/code>\u4ee5\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u548c\u811a\u672c\u3002<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u5b89\u88c5NPM\u5305<\/h3>\n<\/p>\n<p><p>Node.js\u9879\u76ee\u901a\u5e38\u4f9d\u8d56\u4e8e\u591a\u4e2anpm\u5305\uff0c\u4f60\u9700\u8981\u5728WebStorm\u4e2d\u7ba1\u7406\u5b83\u4eec\u3002<\/p>\n<\/p>\n<ol>\n<li>\u5728<strong>Settings\/Preferences<\/strong>\u5bf9\u8bdd\u6846\u4e2d\uff0c\u9009\u62e9<strong>Node.js and NPM<\/strong>\u3002<\/li>\n<li>\u70b9\u51fb<strong>Show npm Scripts<\/strong>\u7a97\u53e3\u5e95\u90e8\u7684&#8230;\u6309\u94ae\uff0c\u6765\u5b89\u88c5\u65b0\u7684npm\u5305\u6216\u8005\u66f4\u65b0\u73b0\u6709\u5305\u3002<\/li>\n<li>\u4f60\u4e5f\u53ef\u4ee5\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u7684<code>package.json<\/code>\u6587\u4ef6\u4e2d\u76f4\u63a5\u6dfb\u52a0\u4f9d\u8d56\uff0c\u5e76\u4e14\u4f7f\u7528WebStorm\u5e95\u90e8\u7684<strong>npm<\/strong>\u5de5\u5177\u7a97\u53e3\u6765\u6267\u884cnpm\u811a\u672c\u3002<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u8fd0\u884c\u4e0e\u8c03\u8bd5NODE.JS\u5e94\u7528<\/h3>\n<\/p>\n<p><p>WebStorm\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684\u8fd0\u884c\u548c\u8c03\u8bd5\u73af\u5883\uff0c\u7528\u4e8eNode.js\u3002<\/p>\n<\/p>\n<ol>\n<li>\u901a\u8fc7\u5728\u4e0a\u65b9\u5de5\u5177\u680f\u4e2d\u9009\u62e9<strong>Run<\/strong>\u83dc\u5355\u4e0b\u7684<strong>Edit Configurations<\/strong>\u6765\u914d\u7f6e\u8fd0\u884c\/\u8c03\u8bd5\u914d\u7f6e\u3002<\/li>\n<li>\u70b9\u51fb\u5de6\u4e0a\u89d2\u7684+<strong>\u53f7\uff0c\u4ece\u5217\u8868\u4e2d\u9009\u62e9<\/strong>Node.js\u3002<\/li>\n<li>\u5728\u6253\u5f00\u7684\u7a97\u53e3\u4e2d\u914d\u7f6eNode.js\u5e94\u7528\u7684\u542f\u52a8\u6587\u4ef6\uff08\u4f8b\u5982<code>app.js<\/code>\u6216<code>server.js<\/code>\uff09\uff0c\u5e76\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u548c\u5176\u4ed6\u8fd0\u884c\u9009\u9879\u3002<\/li>\n<li>\u5e94\u7528\u914d\u7f6e\uff0c\u5e76\u70b9\u51fb<strong>Run<\/strong>\u6216<strong>Debug<\/strong>\u6309\u94ae\u6765\u542f\u52a8\u5e94\u7528\u3002WebStorm\u7684\u8c03\u8bd5\u5668\u4f1a\u81ea\u52a8\u8fde\u63a5\u5230Node.js\u5e94\u7528\uff0c\u5141\u8bb8\u4f60\u653e\u7f6e\u65ad\u70b9\u3001\u68c0\u67e5\u53d8\u91cf\u7b49\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u7684WebStorm\u73af\u5883\u5e94\u8be5\u5df2\u7ecf\u6210\u529f\u914d\u7f6e\u4e3a\u652f\u6301Node.js\u5f00\u53d1\u4e86\u3002WebStorm\u5c06\u4f1a\u4e3a\u4f60\u63d0\u4f9b\u4ee3\u7801\u9ad8\u4eae\u3001\u667a\u80fd\u8865\u5168\u3001\u5b9e\u65f6\u9519\u8bef\u68c0\u6d4b\u3001\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u96c6\u6210\u4ee5\u53ca\u9ad8\u6548\u7684\u4ee3\u7801\u5bfc\u822a\u548c\u91cd\u6784\u5de5\u5177\u3002\u8fd9\u6837\u7684\u914d\u7f6e\u53ef\u4ee5\u6781\u5927\u63d0\u9ad8Node.js\u5f00\u53d1\u7684\u6548\u7387\u548c\u8d28\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5728WebStorm\u4e2d\u914d\u7f6eNode.js\u73af\u5883\uff1f<\/strong><br \/>\n\u8981\u5728WebStorm\u4e2d\u914d\u7f6e\u652f\u6301Node.js\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u6253\u5f00WebStorm\u5e76\u8f6c\u5230\u201cFile\u201d\u83dc\u5355\u3002<\/li>\n<li>\u9009\u62e9 \u201cSettings\u201d\uff08\u6216\u201cPreferences\u201d\uff09\u9009\u9879\u3002<\/li>\n<li>\u5728\u8bbe\u7f6e\u7a97\u53e3\u4e2d\uff0c\u5c55\u5f00\u201cLanguages &amp; Frameworks\u201d\uff08\u8bed\u8a00\u548c\u6846\u67b6\uff09\u5e76\u9009\u62e9\u201cNode.js and NPM\u201d\uff08Node.js\u548cNPM\uff09\u3002<\/li>\n<li>\u5728\u53f3\u4fa7\u7684\u201cNode.js and NPM\u201d\u8bbe\u7f6e\u4e2d\uff0c\u9009\u62e9\u60a8\u5df2\u5b89\u88c5\u7684Node.js\u7248\u672c\u3002<\/li>\n<li>\u70b9\u51fb\u201cApply\u201d\u5e76\u5173\u95ed\u8bbe\u7f6e\u7a97\u53e3\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5982\u4f55\u5728WebStorm\u4e2d\u521b\u5efa\u4e00\u4e2a\u652f\u6301Node.js\u7684\u9879\u76ee\uff1f<\/strong><br \/>\n\u8981\u521b\u5efa\u4e00\u4e2a\u652f\u6301Node.js\u7684\u9879\u76ee\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u6253\u5f00WebStorm\u5e76\u5355\u51fb\u201cCreate New Project\u201d\uff08\u521b\u5efa\u65b0\u9879\u76ee\uff09\u6309\u94ae\u3002<\/li>\n<li>\u5728\u5f39\u51fa\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9 \u201cNode.js\u201d \u9009\u9879\u3002<\/li>\n<li>\u5728\u201cLocation\u201d\u5b57\u6bb5\u4e2d\u6307\u5b9a\u9879\u76ee\u7684\u5b58\u50a8\u4f4d\u7f6e\u3002<\/li>\n<li>\u70b9\u51fb\u201cCreate\u201d\u6309\u94ae\u4ee5\u521b\u5efa\u9879\u76ee\u3002<\/li>\n<li>\u7b49\u5f85WebStorm\u81ea\u52a8\u914d\u7f6e\u60a8\u7684\u9879\u76ee\u4ee5\u652f\u6301Node.js\uff0c\u5e76\u6253\u5f00\u4e00\u4e2a\u5305\u542b\u9ed8\u8ba4\u6587\u4ef6\u7684\u7f16\u8f91\u5668\u7a97\u53e3\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5982\u4f55\u5728WebStorm\u4e2d\u8fd0\u884c\u548c\u8c03\u8bd5Node.js\u5e94\u7528\u7a0b\u5e8f\uff1f<\/strong><br \/>\n\u8981\u5728WebStorm\u4e2d\u8fd0\u884c\u548c\u8c03\u8bd5Node.js\u5e94\u7528\u7a0b\u5e8f\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u5728WebStorm\u4e2d\u6253\u5f00\u60a8\u7684Node.js\u9879\u76ee\u3002<\/li>\n<li>\u5728\u7f16\u8f91\u5668\u4e2d\u627e\u5230\u5305\u542bNode.js\u5e94\u7528\u7a0b\u5e8f\u7684JavaScript\u6587\u4ef6\u3002<\/li>\n<li>\u5355\u51fb\u6587\u4ef6\u7684\u5de6\u4fa7\u4ee5\u6dfb\u52a0\u65ad\u70b9\u3002<\/li>\n<li>\u5355\u51fb\u5de5\u5177\u680f\u4e0a\u7684\u201cRun\u201d\u6309\u94ae\u4ee5\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li>\u5e94\u7528\u7a0b\u5e8f\u5c06\u5728\u5185\u7f6e\u63a7\u5236\u53f0\u4e2d\u663e\u793a\u8f93\u51fa\u3002<\/li>\n<li>\u60f3\u8981\u5728\u8c03\u8bd5\u6a21\u5f0f\u4e0b\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u60a8\u53ef\u4ee5\u5355\u51fb\u5de5\u5177\u680f\u4e0a\u7684\u201cDebug\u201d\u6309\u94ae\u3002\u8fd9\u5c06\u542f\u52a8\u8c03\u8bd5\u4f1a\u8bdd\uff0c\u5e76\u5141\u8bb8\u60a8\u9010\u884c\u6267\u884c\u4ee3\u7801\uff0c\u67e5\u770b\u53d8\u91cf\u503c\u7b49\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"WebStorm \u662f\u4e00\u4e2a\u5f3a\u5927\u7684IDE\uff0c\u4e13\u95e8\u7528\u4e8e\u73b0\u4ee3JavaScript\u5f00\u53d1\uff0c\u652f\u6301Node.js\u9879\u76ee\u7684\u521b\u5efa\u548c\u7ba1\u7406 [&hellip;]","protected":false},"author":3,"featured_media":297685,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/297670"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=297670"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/297670\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/297685"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=297670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=297670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=297670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}