我刚给自己买了一本Mac书,用了很长时间的Windows。
我当时正试图从事我一直在做的一个MeanJS项目。对项目执行npm install
会引发错误
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64/debug.node --module_name=debug --module_path=/Users/Aayush/Work/lishn/repo/lishn-alpha/node_modules/grunt-node-inspector/node_modules/node-inspector/node_modules/v8-debug/build/debug/v0.4.6/node-v46-darwin-x64' (1)
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! code ELIFECYCLE
>
> npm ERR! v8-debug@0.4.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the v8-debug@0.4.6 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the v8-debug package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls v8-debug
npm ERR! There is likely additional logging output above.
我尝试清除缓存。
我尝试使用 sudo
和 --unsafe-perm
安装 node-pre-gyp
我还尝试全新安装一个 MEAN 项目,但出现相同的错误。
我似乎找不到这里的问题所在。
Node Version - 5.0.0
NPM Version - 3.3.10
我尝试升级节点 gyp:
sudo npm install -g node-gyp
它对我有用。
我在这里找到了解决方案,希望它能有所帮助。
Russfrisch 在 4 天前评论道:
我遇到了同样的问题。 在 的版本中更改 grunt-node-inspector 在前面加上">="而不是"~"得到了这个 为我工作。
链接到我找到此解决方案的 github 页面。
链接到我在StackoverFlow上的帖子
大量努力,我遇到了同样的问题。这是因为npm版本与gprc版本不兼容。所以我们需要更新 npm。
npm update
npm install
这似乎是我的节点升级的问题。但是,我使用以下方法解决了它。
首先卸载 cli,清除现金,然后使用这些命令重新安装
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli
然后安装节点预 gyp
npm install -g node-pre-gyp
重新启动终端,看看问题是否已解决。
不适用于所有人,但我更新了节点,当以上都没有时,它为我解决了这个问题
只需使用此命令,它将npm install --unsafe-perm --allow-root
处理此错误
我也面临同样的问题。我为此找到了解决方案。
bcrypt
需要C++、python和node-pre-gyp
。
sudo apt-get install g++
sudo apt-get install -y build-essential python
npm install node-pre-gyp
有关更多详细信息,请查看:安装说明
经过一些调试后,以下依赖项使用的是旧版本的touch
:
./node_modules/bower/node_modules/decompress-zip/package.json: "touch": "0.0.3"
./node_modules/bower/node_modules/lockfile/package.json: "touch": "0"
./node_modules/gulp-nodemon/node_modules/nodemon/package.json: "touch": "1.0.0",
./node_modules/gulp-nodemon/node_modules/touch/package.json: "touch": "./bin/touch.js"
./node_modules/nodemon/package.json: "touch": "~0.0.3",
有了这个,我能够让 meanJS 与节点 5 一起工作。
以下是我运行的命令的历史记录:
git clone https://github.com/meanjs/mean.git
cd mean
nvm install 5
nvm use 5
npm install
which node-gyp
npm install -g node-pre-gyp
sudo xcodebuild -license
npm install
有一些问题,然后:
我添加了以下行:
#!/usr/bin/env node
到文件顶部./mean/node_modules/.bin/touch
然后:
npm install
当然,在重试之前可能会抛出一个sudo rm -rf ./node_modules && npm cache clean
。
正如@ocean800所说,我更新了节点。以下解决方案适用于对我有用的 Ubuntu 16.04,但 OSX 上的类似解决方案可能会解决此问题。
在 Ubuntu 16.04 上,对我有用的是升级节点
在 Ubuntu 16.04 上更新 NodeJS
我正在从下面的上述链接复制解决方案
要更新,您可以安装 n
sudo npm install -g n
然后只是:
sudo n latest
或特定版本
sudo n 8.9.0
然后尝试安装
sudo npm install <package>
希望我的方案可以帮助其他人。我在软件包 bcrypt 上遇到了同样的问题。首先,我按照安妮的建议尝试了npm i -g node-gyp
,但问题仍然存在。然后我再次阅读错误消息以更好地了解问题,并发现脚本无法从头开始构建包 - 因为不存在预编译版本。特别是,它找不到 g++ 命令,所以我解决了使用 sudo apt install build-essential -y
安装build-essential
包的问题。
以下命令对我有用:
sudo npm i -g node-pre-gyp
我也解决了这个问题:只需通过 nvm 将节点重新安装到 LTS 版本:
nvm install --lts
nvm use --lts
然后rm -rf node_modules
npm i
最近在使用自制软件的 Node 的新 OSX 安装上遇到了此错误。Brew 安装了当时最新的 13.8.0
.
我降级了节点的最后一个"稳定"版本。
sudo npm install -g n ## Installs Node Version Switcher
sudo n stable ## To switch to latest stable version
然后我的其余 npm 安装完成并通过了可怕的 gprc 错误!
我有同样的错误,我可以这样解决它
我需要帆布包 -> https://www.npmjs.com/package/canvas
就我而言,我使用了MacOS,因此我安装了依赖项:
$ brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman
仅此而已!
您是否从node_modules文件夹中运行示例?
他们不应该从那里运行。
请改为在项目上创建以下文件:
后数据.js
var Curl = require( 'node-libcurl' ).Curl,
querystring = require( 'querystring' );
var curl = new Curl(),
url = 'http://posttestserver.com/post.php',
data = { //Data to send, inputName : value
'input-arr[0]' : 'input-arr-val0',
'input-arr[1]' : 'input-arr-val1',
'input-arr[2]' : 'input-arr-val2',
'input-name' : 'input-val'
};
//You need to build the query string,
// node has this helper function, but it's limited for real use cases (no support for
array values for example)
data = querystring.stringify( data );
curl.setOpt( Curl.option.URL, url );
curl.setOpt( Curl.option.POSTFIELDS, data );
curl.setOpt( Curl.option.HTTPHEADER, ['User-Agent: node-libcurl/1.0'] );
curl.setOpt( Curl.option.VERBOSE, true );
console.log( querystring.stringify( data ) );
curl.perform();
curl.on( 'end', function( statusCode, body ) {
console.log( body );
this.close();
});
curl.on( 'error', curl.close.bind( curl ) );
使用节点后数据运行.js
ref:https://github.com/JCMais/node-libcurl/issues/98
发生在我身上node 13.7.0
和npm 6.13.6
(macOS Mojave(。
作为错误的一部分,我遇到了以下情况:
found X vulnerabilities (Y moderate, Z high)
run `npm audit fix` to fix them, or `npm audit` for details
运行以下命令解决了问题:
$ npm audit fix
$ npm install
尝试重新安装 XCode 的命令行工具xcode-istall
这对我有用。
卸载node-gyp
后,请尝试再次安装。
sudo npm uninstall -g node-gyp
sudo npm install -g node-gyp
我尝试了所有其他建议的解决方案,但没有一个奏效。我通过从所有根文件夹的名称中删除所有空格和"&"字符来解决此问题。
npm ERR! bcrypt@1.0.3 install: node-pre-gyp install --fallback-to-build
上述错误已通过使用以下命令安装 bcrypt 来修复:
npm --build-from-source install bcrypt@3.0.6
试试这些
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin
然后再次尝试你的命令而不使用 sudo。
例如npm install -g npm@latest
检查此全局安装 sudo 在 Mac 上