我在使用Windows很长一段时间后给自己买了一台macbook。
我正在努力研究我一直在研究的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! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
我也解决了这个问题:只需通过nvm将节点重新安装到LTS版本:
nvm install --lts
nvm use --lts
然后rm -rf node_modules
和npm i
尝试这些
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
查看此link了解更多详情
russfrisch 4天前评论:
我遇到了同样的问题。将grunt-node-inspector的版本更改为前缀“> =”而不是“〜”,这对我有用。
链接到github page我找到了这个解决方案。
这可能对每个人都不起作用,但我更新了节点,当上述情况都没有时,它为我解决了问题
好吧,经过一些调试后,以下依赖项使用旧版本的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上,对我有用的是升级节点
updating nodejs on ubuntu 16.04
我正在通过以下链接复制解决方案
要更新,您可以安装n
sudo npm install -g n
然后就是:
sudo n latest
或特定版本
sudo n 8.9.0
然后尝试安装
sudo npm install <package>
这似乎与我的节点升级有关。我怎么用以下方法解决它。
首先卸载cli,清除缓存,然后使用这些命令重新安装
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli
然后安装node-pre-gyp
npm install -g node-pre-gyp
重新启动终端,查看问题是否已解决。
希望我的方案可以帮助别人。我遇到了与包bcrypt相同的问题。首先,我按照Anne的建议尝试使用npm i -g node-gyp
,但问题仍然存在。然后我再次阅读错误消息以更好地理解问题,并发现脚本无法从头开始构建包 - 因为预编译版本不存在。特别是,它找不到g ++命令,所以我解决了用build-essential
安装sudo apt install build-essential -y
包的问题。
你从node_modules文件夹运行示例?
他们不应该从那里逃跑。
而是在项目上创建以下文件:
后data.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 ) );
使用node post-data.js运行
以下命令对我有用:
sudo npm i -g node-pre-gyp