{"id":15198,"date":"2021-01-15T08:25:13","date_gmt":"2021-01-15T00:25:13","guid":{"rendered":"http:\/\/blog.idc.net\/15198\/"},"modified":"2021-01-15T08:25:13","modified_gmt":"2021-01-15T00:25:13","slug":"ubuntu%e4%b8%8b%e5%bf%ab%e9%80%9f%e5%ae%89%e8%a3%85-nodejs-%e5%92%8c-electron","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/15198\/","title":{"rendered":"Ubuntu\u4e0b\u5feb\u901f\u5b89\u88c5 Nodejs \u548c Electron"},"content":{"rendered":"<div class=\"idc_table\">\n<p>\u67e5\u627e\u65f6\u95f4\u7ba1\u7406\u8f6f\u4ef6\u7684\u65f6\u5019\u53d1\u73b0\u4e86superProductivity\u8fd9\u4e2a\u7a0b\u5e8f\uff0c\u4f7f\u7528electron\u8fdb\u884c\u5f00\u53d1\uff0c\u4e8e\u662f\u770b\u4e86\u4e00\u4e0b\u4ecb\u7ecd\uff0c\u624b\u75d2\u4e86\uff0c\u5c1d\u8bd5\u8fdb\u884c\u73af\u5883\u642d\u5efa\uff0c\u4e0b\u4e00\u6b65\u6162\u6162\u8865\u9f50\u524d\u7aef\u77e5\u8bc6\u5427\u3002<\/p>\n<p>nodejs\u5b89\u88c5<\/p>\n<p>nodejs\u7684\u7248\u672c\u66f4\u65b0\u8f83\u5feb\uff0c\u6240\u4ee5\u53ef\u80fd\u4e00\u4e2a\u7cfb\u7edf\u4e0a\u5b58\u5728\u591a\u4e2a\u7248\u672c\uff0c\u7ba1\u7406\u5de5\u5177\u4e5f\u53ef\u4ee5\u591a\u79cd\u591a\u6837\uff0c\u6211\u9009\u62e9\u4f7f\u7528nvm\u8fdb\u884c\u5b89\u88c5\uff0c\u4e00\u4e2a\u539f\u56e0\u662f\u7ba1\u7406\u7b80\u5355\uff0c\u53e6\u5916\u4e00\u4e2a\u662f\u4e0d\u7528\u5148\u5b89\u88c5nodejs\u518d\u8fdb\u884c\u5347\u7ea7\u3002<\/p>\n<p>1.\u5b89\u88c5nvm<br \/>\u5148\u67e5\u770bnvm\u7684\u7248\u672c,\u7136\u540e\u66ff\u6362\u4e0b\u5217\u811a\u672c\u5730\u5740\u4e2d\u7684\u7248\u672c\u4fe1\u606f\u83b7\u5f97nvm<br \/>curl -o- https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.10\/install.sh&nbsp; | bash<\/p>\n<p>2.\u67e5\u770bnvm\u7248\u672c<br \/>nvm -v<\/p>\n<p>3.\u5982\u679c\u51fa\u73b0\u627e\u4e0d\u5230nvm\uff0c\u4e00\u822c\u5e94\u8be5\u4e3a\u914d\u7f6e\u95ee\u9898\uff0c\u5728 ~\/.bash.rc ~\/.profile or ~\/.bash_profile \u68c0\u67e5\u662f\u5426\u6709\u5982\u4e0b\u8bdd\u8bed\uff0c<br \/>export NVM_DIR=\"\/home\/carl\/.nvm\"<br \/>[ -s \"$NVM_DIR\/nvm.sh\" ] &amp;&amp; . \"$NVM_DIR\/nvm.sh\"&nbsp; # This loads nvm<\/p>\n<p>4.\u5b89\u88c5node<br \/>\u67e5\u770b\u53ef\u5b89\u88c5node\u7684\u7248\u672c<br \/>nvm ls-remote<\/p>\n<p>\u5f53\u7136\u5b89\u88c5\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\u5982<\/p>\n<p>\u00d7\u00d7\u5b89\u88c5\u7a33\u5b9a\u7248<br \/>nvm install stable<br \/>\u00d7\u00d7\u5b89\u88c5\u7279\u5b9a\u7248\u672c\uff0c\u7248\u672c\u53f7\u53ef\u4ee5\u4ece\u4e0a\u9762\u7684\u67e5\u770b\u7248\u672c\u91cc\u7684\u7ed3\u679c\u627e<br \/>nvm install 8.11.1<br \/>\u00d7\u00d7\u67e5\u770b\u5f53\u524dnode \u7248\u672c<br \/>nvm current<br \/>\u00d7\u00d7\u67e5\u770b\u6240\u6709node\u7248\u672c<br \/>nvm ls<br \/>\u00d7\u00d7\u5207\u6362\u4f7f\u7528\u7248\u672c<br \/>nvm use&nbsp; 8.11.1<\/p>\n<p><strong>\u5b89\u88c5electron<\/strong><\/p>\n<p>\u7f51\u4e0a\u5f88\u591a\u5b89\u88c5electron\u4f7f\u7528\u7684\u662fnpm\uff0c\u4f46\u662f\u6211\u8fd9\u91cc\u6267\u884c\u662f\u6709\u95ee\u9898\u7684\uff0c\u5b89\u88c5\u5931\u8d25\uff0c\u63d0\u793a\u662f\u6743\u9650\u95ee\u9898\uff0c\u6211\u5df2\u7ecf\u4f7f\u7528sudo\u8fdb\u884c\u5b89\u88c5\u4e86\uff0c\u53ef\u80fd\u662f\u7f51\u7edc\u6216\u8005\u914d\u7f6e\u90a3\u91cc\u6ca1\u5bf9\u5427\uff0c\u6ca1\u5fc5\u8981\u5728\u8fd9\u4e0a\u9762\u8fdb\u884c\u7ea0\u7ed3\uff0c\u67e5\u770b\u4e86\u7f51\u4e0a\u7684\u65b9\u6cd5\u6211\u9009\u7528\u7684cnpm\u8fdb\u884c\u5b89\u88c5\uff0c\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u4e00\u4e0b\u662f\u5426\u80fd\u591f\u8fdb\u884c\u5b89\u88c5<br \/>\u00d7\u00d7npm\u5b89\u88c5<br \/>sudo npm install electron --save-dev --save-exact<br \/>\u00d7\u00d7cnpm\u5b89\u88c5<br \/>npm install -g cnpm --registry=https:\/\/registry.npm.taobao.org<br \/>\u00d7\u00d7\u4f7f\u7528cnpm\u8fdb\u884c\u5b89\u88c5\uff0c\u4f7f\u7528\u65b9\u6cd5\u548cnpm\u76f8\u540c<br \/>cnpm install -g electron<\/p>\n<p><strong>\u4e0b\u9762\u5173\u4e8e<span style=\"color: #ff0000\">Node.js<\/span>\u7684\u5185\u5bb9\u4f60\u53ef\u80fd\u4e5f\u559c\u6b22<\/strong>\uff1a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u627e\u65f6\u95f4\u7ba1\u7406\u8f6f\u4ef6\u7684\u65f6\u5019\u53d1\u73b0\u4e86superProductivity\u8fd9\u4e2a\u7a0b\u5e8f\uff0c\u4f7f\u7528electron\u8fdb\u884c\u5f00\u53d1\uff0c\u4e8e\u662f\u770b\u4e86 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-15198","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/15198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=15198"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/15198\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=15198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=15198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=15198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}