{"id":8892,"date":"2022-11-29T09:42:23","date_gmt":"2022-11-29T01:42:23","guid":{"rendered":"http:\/\/123.57.164.21\/?p=8892"},"modified":"2022-11-29T09:42:23","modified_gmt":"2022-11-29T01:42:23","slug":"npm%e5%ae%89%e8%a3%85%e5%85%a8%e5%b1%80%e6%a8%a1%e5%9d%97%ef%bc%8crequire%e6%97%b6%e6%8a%a5error-cannot-find-module-%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=8892","title":{"rendered":"npm\u5b89\u88c5\u5168\u5c40\u6a21\u5757\uff0crequire\u65f6\u62a5Error: Cannot find module \u7684\u89e3\u51b3\u529e\u6cd5"},"content":{"rendered":"\n<p>\u4e0b\u5348\u4f7f\u7528npm\u5b89\u88c5\u201ccheerio\u201d\u3002<\/p>\n\n\n\n<p>npm\u5b89\u88c5\u6709\u4e24\u79cd\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ul><li>\u672c\u5730 # npm install cheerio<\/li><li>\u5168\u5c40 # npm install cheerio -g<\/li><\/ul>\n\n\n\n<p>\u5168\u5c40\u5b89\u88c5\u597d\u4e4b\u540e\uff0c\u8d76\u7d27\u6253\u5f00node,\u8bd5\u7740require\u521a\u5b89\u88c5\u7684\u5168\u5c40\u5305\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">var n = require(\u2018cheerio\u2018)\nError: Cannot find module \u2018cheerio\u2018\nat Function.Module._resolveFilename (module.js:469:15)\nat Function.Module._load (module.js:417:25)\n<\/pre>\n\n\n\n<p>\u5931\u8d25\u4e86\uff01\uff01\uff01<\/p>\n\n\n\n<p>\u7f51\u4e0a\u67e5\u4e86\u4e00\u5927\u5806\u535a\u5ba2\uff0c\u539f\u6765\u662f\u5fd8\u4e86\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n\n\n\n<p>NODE_PATH<\/p>\n\n\n\n<p>\u5173\u952e\u7684\u5730\u65b9\u6765\u4e86\uff1a<\/p>\n\n\n\n<p>NODE_PATH\u600e\u4e48\u5199\uff1f<\/p>\n\n\n\n<p>\u4e0d\u8981\u8bef\u4ee5\u4e3a\u5c31\u662f\u4f60\u7684\u521a\u8bbe\u7f6e\u7684\u5168\u5c40\u76ee\u5f55\uff0c\u6211\u90a3\u6837\u586b\u5199\u4e86\u3002\u5b8c\u5168\u6ca1\u7528\u3002<\/p>\n\n\n\n<p>\u5b9e\u9645\u4e0a\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\u67e5\u770b\u4e00\u4e0bcheerio\u5230\u5e95\u5728\u54ea\u91cc\u3002\u7136\u540eNODE_PATH\u5c31\u8bbe\u7f6e\u54ea\u91cc<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">npm list -g<\/pre>\n\n\n\n<p><br>\u6211\u7684\u7cfb\u7edf\u663e\u793a\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/usr\/node-v6.10.0-linux-x64\/lib\/node_modules\/node_global\/lib\n\u251c\u2500\u252c cheerio@0.22.0\n\u2502 \u251c\u2500\u252c css-select@1.2.0\n\u2502 \u2502 \u251c\u2500\u2500 boolbase@1.0.0\n\u2502 \u2502 \u251c\u2500\u2500 css-what@2.1.0\n\u2502 \u2502 \u251c\u2500\u2500 domutils@1.5.1\n\u2502 \u2502 \u2514\u2500\u2500 nth-check@1.0.1\n\u2502 \u251c\u2500\u252c dom-serializer@0.1.0\n\u2502 \u2502 \u2514\u2500\u2500 domelementtype@1.1.3\n\u2502 \u251c\u2500\u2500 entities@1.1.1\n\u2502 \u251c\u2500\u252c htmlparser2@3.9.2\n\u2502 \u2502 \u251c\u2500\u2500 domelementtype@1.3.0\n\u2502 \u2502 \u251c\u2500\u2500 domhandler@2.3.0\n\u2502 \u2502 \u251c\u2500\u2500 inherits@2.0.3\n\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/pre>\n\n\n\n<p>\u6211\u662f\u8fd9\u6837\u914d\u7f6e\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vim \/etc\/profile<\/pre>\n\n\n\n<p>\u6dfb\u52a0\u4e0b\u9762\u4e24\u884c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export NODE_HOME=\/usr\/node-v6.10.0-linux-x64\/lib\/node_modules\/node_global\nexport NODE_PATH=$NODE_HOME:$NODE_HOME\/lib\/node_modules<\/pre>\n\n\n\n<p>\u4fdd\u5b58\u9000\u51fa<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">source\u00a0\/etc\/profile \u4f7f\u5176\u751f\u6548<\/pre>\n\n\n\n<p>\u518d\u6b21\u6d4b\u8bd5require\uff0c\u4e0d\u518d\u62a5\u9519\u4e86<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[root@aliyun node-v6.10.0-linux-x64]#node\n> var n = require(\u2018cheerio\u2018)\n\nundefined\n><\/pre>\n\n\n\n<p>\u603b\u7ed3\uff1a<\/p>\n\n\n\n<p>\u60f3\u8981\u5728js\u6587\u4ef6\u4e2d\u901a\u8fc7require\uff08\u2018\u6a21\u5757\u540d\u2019\uff09\u6765\u4f7f\u7528\u5168\u5c40\u5b89\u88c5\u7684\u6a21\u5757\uff0c\u5fc5\u987b\u914d\u7f6e\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff0c\u624d\u53ef\u4f7f\u7528\u3002\u5426\u5219\uff0c\u6267\u884c\u65f6\uff0c\u4f1a\u62a5\u9519\uff0c\u610f\u4e3a:\u6ca1\u6709\u627e\u5230\u8981\u4f7f\u7528\u7684\u8be5\u6a21\u5757\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u5348\u4f7f\u7528npm\u5b89\u88c5\u201ccheerio\u201d\u3002 npm\u5b89\u88c5\u6709\u4e24\u79cd\u6a21\u5f0f\uff1a \u672c\u5730 # npm install cheeri [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8892"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8892"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8892\/revisions"}],"predecessor-version":[{"id":8893,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8892\/revisions\/8893"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}