{"id":2524,"date":"2022-05-20T06:03:46","date_gmt":"2022-05-19T21:03:46","guid":{"rendered":"https:\/\/blog.wsd.sh\/?p=2524"},"modified":"2022-09-10T08:01:08","modified_gmt":"2022-09-09T23:01:08","slug":"truffle%e3%81%aeinsall-%e3%81%a7error","status":"publish","type":"post","link":"https:\/\/blog.wsd.sh\/?p=2524","title":{"rendered":"<small>truffle\u306einsall \u3067error \uff1anpm ERR! code 127\u3000<\/small>"},"content":{"rendered":"<p>\uff11\uff0e\u7d50\u8ad6\u3000truffle init\u306f\u3001\u3042\u304d\u3089\u3081\u305f<br \/>\n\u30fb\u4eca\u306e\u3068\u3053\u308dTruffle\u306fnpm <7\u3068\u306e\u307f\u4e92\u63db\u6027\u304c\u3042\u308b\n\u30fb\u4e00\u5fdcnstall\u306f\u51fa\u6765\u305f\u304c\u3001truffle init\u3067error\u304c\u51fa\u308b\n\u30fb\u3069\u3046\u3057\u3066\u3082\u52d5\u304b\u3057\u305f\u304b\u3063\u305f\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001truffle init\u306f\u4fdd\u7559\n\n<br \/>\n\uff12\uff0etruffle\u3092install\u3057\u305f\u6642\u306eERR<\/p>\n<pre>\r\n# npm install -g truffle\r\n\uff1a\r\nnpm ERR! code 127\r\nnpm ERR! path \/root\/.nvm\/versions\/node\/v17.9.0\/lib\/node_modules\/truffle\/node_modules\/leveldown\r\nnpm ERR! command failed\r\nnpm ERR! command sh -c node-gyp-build\r\nnpm ERR! sh: line 1: node-gyp-build: command not found\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR!     \/root\/.npm\/_logs\/2022-05-19T20_47_14_963Z-debug-0.log\r\n#\r\n<\/pre>\n<p>\uff13\uff0enode-gyp-build\u3092\u5165\u308c\u308b<\/p>\n<pre>\r\n# npm install node-gyp-build\r\n\r\nadded 1 package, and audited 4 packages in 2s\r\n\r\n1 package is looking for funding\r\n  run `npm fund` for details\r\n\r\nfound 0 vulnerabilities\r\n# npm ls |grep node-gyp-build\r\nmqq node-gyp-build@4.4.0\r\n#\r\n<\/pre>\n<p>\uff15\uff0enode-gyp-build\u306e\u5b58\u5728\u78ba\u8a8d<\/p>\n<pre>\r\n# which node-gyp-build\r\n\/usr\/bin\/which: no node-gyp-build in (\/root\/.nvm\/versions\/node\/v17.9.0\/bin:\/root\/.local\/bin:\/root\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/var\/lib\/snapd\/snap\/bin)\r\n<\/pre>\n<p>\uff14\uff0epath\u3092\u8ffd\u52a0<\/p>\n<pre>\r\n# vi ~\/.bashrc\r\n\r\nPATH=\"$HOME\/.\/node_modules\/.bin\/:$PATH\"\r\nexport PATH\r\n\r\n# source ~\/.bashrc\r\n<\/pre>\n<p>\uff16\uff0e\u307e\u305finstall\u306b\u5931\u6557\u3059\u308b<br \/>\n\u305d\u3053\u3067\u3001nvm\u3067nodejs\u309218\u306b\u4e0a\u3052\u308b<\/p>\n<pre>\r\n# nvm install 18\r\nDownloading and installing node v18.2.0...\r\nDownloading https:\/\/nodejs.org\/dist\/v18.2.0\/node-v18.2.0-linux-x64.tar.xz...\r\n######################################################################### 100.0%\r\nComputing checksum with sha256sum\r\nChecksums matched!\r\nNow using node v18.2.0 (npm v8.9.0)\r\n[root@localhost ~]# node -v\r\nv18.2.0\r\n#\r\n<\/pre>\n<p>\uff17\uff0e\u518d\u5ea6install\u3060\u304c\u5931\u6557\u3059\u308b<\/p>\n<pre>\r\n# npm install -g truffle\r\n\uff1a\r\nnpm ERR! code 127\r\nnpm ERR! path \/root\/.nvm\/versions\/node\/v18.2.0\/lib\/node_modules\/truffle\/node_modules\/leveldown\r\nnpm ERR! command failed\r\nnpm ERR! command sh -c node-gyp-build\r\nnpm ERR! sh: line 1: node-gyp-build: command not found\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR!     \/root\/.npm\/_logs\/2022-05-19T21_35_53_530Z-debug-0.log\r\n[root@localhost ~]#\r\n<\/pre>\n<p>\uff18\uff0egithub\u306b\u4ee5\u4e0b\u306e\u66f8\u304d\u8fbc\u307f\u304c\u3042\u308b\u306e\u3067\u3001npm@6\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/p>\n<p>Hey @ukyo717, for now Truffle is only compatible with npm < 7. It looks like you are using version 8, could you try downgrading your npm and installing again?\nYou can do this by entering\n\n\n\n<pre>\r\n# npm install -g npm@6\r\n# node -v\r\nv18.2.0\r\n# npm install -g truffle\r\n\uff1a\r\n+ truffle@5.5.14\r\nadded 1133 packages from 768 contributors in 510.882s\r\n#\r\n<\/pre>\n<p>\uff19\uff0e truffle init<br \/>\n\u30fb\u3053\u3053\u307e\u3067\u3084\u3063\u3066\u3001\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u3067\u305f\u3002<br \/>\n\u30fbError: Cannot find module &#8216;.\/uws_linux_x64_108.node&#8217;<\/p>\n<pre>\r\n# truffle init\r\nThis version of \u03bcWS is not compatible with your Node.js build:\r\n\r\nError: Cannot find module '.\/uws_linux_x64_108.node'\r\nFalling back to a NodeJS implementation; performance may be degraded.\r\n\r\n^C\r\n#\r\n<\/pre>\n<p>\uff11\uff10\uff0e\u5bfe\u5fdc<br \/>\n\u30fb&#8217;.\/uws_linux_x64_108.&#8221; &#8221; node&#8217;\u304c\u691c\u7d22\u3067\u5f15\u304d\u5f53\u305f\u3089\u306a\u3044<\/p>\n<p>\uff11\uff11\uff0e\u624b\u9806\u3092\u898b\u76f4\u3057\u305f\u3089\u3001node\u306eversion\u304c \uff1c7 \u306b\u306a\u3063\u3066\u3044\u306a\u3044<br \/>\n\u30fb\u3069\u3046\u3057\u3066\u3082\u52d5\u304b\u3057\u305f\u304b\u3063\u305f\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001truffle init\u306f\u4e00\u65e6\u4fdd\u7559<\/p>\n<p>\uff11\uff12\uff0e\u53c2\u8003<br \/>\n<a href=\"https:\/\/github.com\/trufflesuite\/truffle\/issues\/4692\">https:\/\/github.com\/trufflesuite\/truffle\/issues\/4692<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uff11\uff0e\u7d50\u8ad6\u3000truffle init\u306f\u3001\u3042\u304d\u3089\u3081\u305f \u30fb\u4eca\u306e\u3068\u3053\u308dTruffle\u306fnpm<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/2524"}],"collection":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2524"}],"version-history":[{"count":31,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/2524\/revisions"}],"predecessor-version":[{"id":3761,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=\/wp\/v2\/posts\/2524\/revisions\/3761"}],"wp:attachment":[{"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wsd.sh\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}