【问题标题】:`node-pre-gyp install --fallback-to-build` failed during MeanJS installation on OSX在 OSX 上安装 MeanJS 期间,`node-pre-gyp install --fallback-to-build` 失败
【发布时间】:2016-02-01 12:42:07
【问题描述】:

在使用 Windows 很长时间后,我刚给自己买了一本 mac book。

我正在尝试从事我一直在从事的 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

【问题讨论】:

  • 我发现一些线程建议降级 node 和 npm。我还没有验证这是否有效。我想解决这个问题而不必降级。
  • 我建议至少降级到4.2.x,因为它是最新的长期版本,几周前才发布。如果它在那里工作,然后尝试使用5.x 看看有什么问题,有可能npm 模块还没有更新到处理5.x,因为它只有几天?或者至少不要在 npm 或 node 中使用 sudo 来避免一些麻烦,并考虑使用nvm
  • node-pre-gyp 尝试构建时会发生什么? (它是 npm 错误上方的文本)。此外,您用于构建的节点版本是 4.1.1 npm ERR! node v4.1.1

标签: node.js macos npm meanjs


【解决方案1】:

我已经尝试升级 node-gyp:

sudo npm install -g node-gyp

它对我有用。

我找到了解决方案here,希望能帮到你。

【讨论】:

  • 添加评论即可。在npm install -g node-gyp 中,-g 表示全局 安装它,而不是升级它。
  • 对我也不起作用。有没有其他方法可以解决这个问题?
  • 对我来说,它只有在我安装 package-lock.json 中找到的确切版本时才有效对我来说,正确的命令是:npm i -g node-gyp@3.8.0
  • 谢谢。这真的有效!!sudo npm install -g node-gyp
【解决方案2】:

russfrisch 4 天前发表评论:

我遇到了同样的问题。更改版本为 grunt-node-inspector 在前面加上 ">=" 而不是 "~" 得到这个 为我工作。

链接到github page 我在其中找到了此解决方案。

Link to my post on StackoverFlow

【讨论】:

【解决方案3】:

这可能不适用于每个人,但我更新了节点并在以上都没有的情况下为我解决了问题

【讨论】:

    【解决方案4】:

    经过多次努力,我遇到了同样的问题。这是因为 npm 版本与 gprc 版本不兼容。 所以我们需要更新 npm。

    npm update
    npm install 
    

    【讨论】:

      【解决方案5】:

      这似乎与我的节点升级有关。我是如何用以下方法解决的。

      先卸载cli,清除cashe,再用这些命令重新安装

      npm uninstall -g @angular/cli
      npm cache clean
      npm install -g @angular/cli
      

      然后安装node-pre-gyp

      npm install -g node-pre-gyp
      

      重启终端看看问题是否解决。

      【讨论】:

        【解决方案6】:

        我也解决了这个问题: 只需通过 nvm 将节点重新安装到 LTS 版本:

        nvm install --lts
        
        nvm use --lts
        

        然后rm -rf node_modules 还有npm i

        【讨论】:

          【解决方案7】:

          只要使用这个命令,它就会处理这个错误npm install --unsafe-perm --allow-root

          【讨论】:

          • 谢谢,困扰我很久了。
          【解决方案8】:

          我也面临同样的问题。我找到了解决方案。

          bcrypt 需要 C++、python 和 node-pre-gyp

          sudo apt-get install g++
          sudo apt-get install -y build-essential python
          npm install node-pre-gyp
          

          更多详情请查看:Installation-Instructions

          【讨论】:

            【解决方案9】:

            好吧,经过一些调试后,以下依赖项使用的是旧版本的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

            【讨论】:

            • 我尝试安装 node-pre-gyp 的旧版本:npm install node-pre-gyp@v0.7.x。它对我有用。我不知道为什么新版本不起作用。
            【解决方案10】:

            正如@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>
            

            【讨论】:

            【解决方案11】:

            希望我的方案可以帮助其他人。 我对 bcrypt 包也有同样的问题。首先,我按照 Anne 的建议尝试了 npm i -g node-gyp,但问题仍然存在。然后我再次阅读错误消息以更好地理解问题并发现脚本无法从头开始构建包 - 因为预编译版本不存在。特别是它找不到 g++ 命令,所以我解决了使用sudo apt install build-essential -y 安装build-essential 包。

            【讨论】:

              【解决方案12】:

              以下命令对我有用:

              sudo npm i -g node-pre-gyp
              

              【讨论】:

              • 您不应该需要sudo npm - 它会产生永久权限问题:stackoverflow.com/a/29787502/1614973
              • 是的,怎么会这样?两个 npm 命令似乎都指向同一个程序。 IE。 ``` 哪个 npm /usr/local/bin/npm sudo 哪个 npm /usr/local/bin/npm ```
              【解决方案13】:

              我最近在使用 homebrew 安装新的 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 错误!

              【讨论】:

                【解决方案14】:

                您是否从 node_modules 文件夹运行示例?

                他们不应该从那里跑掉。

                改为在您的项目中创建以下文件:

                post-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 ) );
                

                使用节点 post-data.js 运行

                参考:https://github.com/JCMais/node-libcurl/issues/98

                【讨论】:

                  【解决方案15】:

                  发生在 node 13.7.0npm 6.13.6 (ma​​cOS Mojave) 上。

                  我有以下错误:

                  found X vulnerabilities (Y moderate, Z high)
                    run `npm audit fix` to fix them, or `npm audit` for details
                  

                  并运行以下修复问题:

                  1. $ npm audit fix

                  2. $ npm install

                  【讨论】:

                    【解决方案16】:

                    尝试使用xcode-istall重新安装XCode的命令行工具

                    这对我有用。

                    【讨论】:

                      【解决方案17】:
                      npm ERR! bcrypt@1.0.3 install: node-pre-gyp install --fallback-to-build
                      

                      上述错误已通过使用以下命令安装 bcrypt 得到修复:

                      npm --build-from-source install bcrypt@3.0.6
                      

                      【讨论】:

                      • 请格式化代码 sn-ps 和命令。
                      【解决方案18】:

                      卸载node-gyp后,再次尝试安装。

                      sudo npm uninstall -g node-gyp
                      sudo npm install -g node-gyp
                      

                      【讨论】:

                        【解决方案19】:

                        试试这些

                        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
                        

                        查看global installs sudo fail on mac了解更多详情

                        【讨论】:

                          猜你喜欢
                          • 2018-08-05
                          • 1970-01-01
                          • 2016-02-12
                          • 2021-01-13
                          • 1970-01-01
                          • 2020-02-05
                          • 1970-01-01
                          • 2018-12-08
                          • 2020-01-17
                          相关资源
                          最近更新 更多