web-dev-qa-db-ja.com

npmインストールの実行中のnode-gypエラー

プロジェクトからnpm installを実行していて、node-gypでこの奇妙なエラーが発生しています。

> [email protected] install /home/charizard/Open/terminal-codelearn/node_modules/pty.js
> node-gyp rebuild

npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/nan
npm http GET https://registry.npmjs.org/tinycolor
npm http GET https://registry.npmjs.org/options
gyp ERR! configure error 
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack     at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:65:16)
gyp ERR! stack     at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! stack     at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:228:20)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:110:9
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:659:7)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:106:17)
gyp ERR! stack     at maybeClose (child_process.js:773:16)
gyp ERR! stack     at Socket.<anonymous> (child_process.js:986:11)
gyp ERR! stack     at Socket.EventEmitter.emit (events.js:103:17)
gyp ERR! stack     at Pipe.close (net.js:458:12)
gyp ERR! System Linux 3.5.0-37-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/charizard/Open/terminal-codelearn/node_modules/pty.js
gyp ERR! node -v v0.11.8-pre
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm ERR! weird error 1

Npm listを実行すると、次のメッセージが表示されます。

npm ERR! missing: pty.js@>=0.2.2, required by [email protected]
npm ERR! not ok code 0

申し訳ありませんが、nodejsは完全に初めてです。

11
Charizard_

これが発生する理由は、node-gyp-pre[email protected]部分を-1として評価するためです。次に、インストールは404を受け取り、失敗します。

gyp http GET http://nodejs.org/dist/v0.8.-1/node-v11.8.-1.tar.gz
gyp http 404 http://nodejs.org/dist/v0.8.-1/node-v11.8.-1.tar.gz

この問題を解決するには、Node.jsの安定版リリースを使用してください。それ以外の場合は、Nodeソースを横に配置し、--nodedirフラグを使用する必要があります。

npm install --nodedir=/node/src/

この問題の詳細については、 ここ を参照してください。

16
hexacyanide

ノードのバージョンを安定したバージョンにアップグレードすることでこれを解決しました(たとえば、「プレ」バージョンではない-バージョンは0.8.13-pre)。

Sudo npm install -g n # install node version manager "n"
Sudo n stable # install the latest stable version of node
5
Himanshu sharma