{"id":56273,"date":"2023-10-19T15:37:51","date_gmt":"2023-10-19T07:37:51","guid":{"rendered":"https:\/\/www.techphant.cn\/blog\/56273.html"},"modified":"2023-10-19T15:37:51","modified_gmt":"2023-10-19T07:37:51","slug":"synljckfwq","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/56273.html","title":{"rendered":"\u4f7f\u7528Nodejs\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668"},"content":{"rendered":"

  \u4e32\u53e3\u670d\u52a1\u5668\u662f\u4e00\u79cd\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8fde\u63a5\u5230\u5916\u90e8\u8bbe\u5907\uff0c\u5b9e\u73b0\u6570\u636e\u4ea4\u6362\u3002Nodejs\u662f\u4e00\u79cd\u7528\u4e8e\u6784\u5efa\u670d\u52a1\u5668\u7aef\u5e94\u7528\u7a0b\u5e8f\u7684JavaScript\u8fd0\u884c\u65f6\u73af\u5883\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efa\u3001\u6d4b\u8bd5\u548c\u90e8\u7f72\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Nodejs\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668\uff0c\u4ee5\u53ca\u5b83\u7684\u4f18\u52bf\u3002<\/p>\n

\u4e3a\u4ec0\u4e48\u4f7f\u7528Nodejs\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668<\/h2>\n

  Nodejs\u7684\u975e\u963b\u585eI\/O\u6a21\u578b\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u6709\u6548\u5730\u5904\u7406\u4e32\u53e3\u670d\u52a1\u5668\u7684\u6570\u636e\u3002\u5b83\u53ef\u4ee5\u66f4\u597d\u5730\u5904\u7406\u5927\u91cf\u5e76\u53d1\u8bf7\u6c42\uff0c\u63d0\u9ad8\u6574\u4f53\u6027\u80fd\u3002\u6b64\u5916\uff0cNodejs\u53ef\u4ee5\u8f7b\u677e\u6784\u5efa\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u8de8\u8d8a\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u786c\u4ef6\uff0c\u6765\u5b9e\u73b0\u4e32\u53e3\u670d\u52a1\u5668\u7684\u8fde\u63a5\u3002<\/p>\n

\u5982\u4f55\u4f7f\u7528Nodejs\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668<\/h2>\n

  \u5b89\u88c5Nodejs<\/h3>\n

  \u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Nodejs\uff0c\u53ef\u4ee5\u4ece\u5b98\u7f51\u4e0b\u8f7d\u6700\u65b0\u7684\u5b89\u88c5\u5305\uff0c\u5e76\u5b89\u88c5\u5230\u672c\u5730\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u201cnode -v\u201d\u6765\u67e5\u770b\u5f53\u524dNodejs\u7684\u7248\u672c\u53f7\u3002<\/p>\n

  \u5b89\u88c5\u4e32\u53e3\u670d\u52a1\u5668\u5e93<\/h3>\n

  \u5176\u6b21\uff0c\u9700\u8981\u5b89\u88c5\u4e32\u53e3\u670d\u52a1\u5668\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528npm\u5b89\u88c5\u201cserialport\u201d\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\u547d\u4ee4\u201cnpm install serialport\u201d\u6765\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u5728Nodejs\u4e2d\u5f15\u5165\u201cserialport\u201d\u5e93\uff0c\u4f7f\u7528\u5b83\u6765\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668\u3002<\/p>\n

  \u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668<\/h3>\n

  \u6700\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528Nodejs\u7684\u201cserialport\u201d\u5e93\u6765\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668\uff0c\u9996\u5148\u9700\u8981\u83b7\u53d6\u4e32\u53e3\u670d\u52a1\u5668\u7684\u7aef\u53e3\u53f7\uff0c\u7136\u540e\u4f7f\u7528\u201cserialport\u201d\u5e93\u7684\u201copen\u201d\u65b9\u6cd5\u6765\u6253\u5f00\u4e32\u53e3\u670d\u52a1\u5668\uff0c\u5e76\u4f7f\u7528\u201cwrite\u201d\u65b9\u6cd5\u53d1\u9001\u6570\u636e\uff0c\u4f7f\u7528\u201con\u201d\u65b9\u6cd5\u76d1\u542c\u4e32\u53e3\u670d\u52a1\u5668\u7684\u6570\u636e\u4f20\u8f93\uff0c\u6700\u540e\u4f7f\u7528\u201cclose\u201d\u65b9\u6cd5\u5173\u95ed\u4e32\u53e3\u670d\u52a1\u5668\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  Nodejs\u53ef\u4ee5\u7528\u4e8e\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u6709\u6548\u5730\u5904\u7406\u4e32\u53e3\u670d\u52a1\u5668\u7684\u6570\u636e\uff0c\u5e76\u53ef\u4ee5\u6784\u5efa\u8de8\u5e73\u53f0\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/strong>\u8981\u4f7f\u7528Nodejs\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668\uff0c\u9700\u8981\u5148\u5b89\u88c5Nodejs\uff0c\u7136\u540e\u5b89\u88c5\u4e32\u53e3\u670d\u52a1\u5668\u5e93\uff0c\u6700\u540e\u4f7f\u7528\u201cserialport\u201d\u5e93\u7684\u201copen\u201d\u3001\u201cwrite\u201d\u3001\u201con\u201d\u548c\u201cclose\u201d\u65b9\u6cd5\u6765\u8fde\u63a5\u4e32\u53e3\u670d\u52a1\u5668\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4e32\u53e3\u670d\u52a1\u5668\u662f\u4e00\u79cd\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u8fde\u63a5\u5230\u5916\u90e8\u8bbe\u5907\uff0c\u5b9e\u73b0\u6570\u636e\u4ea4\u6362\u3002Nodejs\u662f\u4e00\u79cd\u7528\u4e8e\u6784\u5efa\u670d\u52a1\u5668\u7aef\u5e94\u7528\u7a0b\u5e8f\u7684JavaScript\u8fd0\u884c\u65f6\u73af\u5883\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5feb\u901f<\/p>\n","protected":false},"author":1,"featured_media":4132,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[69],"class_list":["post-56273","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-cktx"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/56273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=56273"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/56273\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/4132"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=56273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=56273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=56273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}