【问题标题】:Error with npm install - a pre-gyp errornpm install 出错 - 一个 pre-gyp 错误
【发布时间】:2017-02-02 02:49:57
【问题描述】:

我想使用 npm 安装 this angular 2 日历。尝试使用npm安装它然后下载并尝试安装它。在这两种情况下都失败了。

我在 Windows 上,之前在尝试安装 angular2 CLI 时遇到此错误。现在我收到这个包的相同错误,我不知道如何纠正它。我尝试卸载 CLI,然后清除缓存,但没有成功。

有人可以看看这个错误,让我知道我需要采取哪些步骤来纠正这个问题..

出现在 cmd 上的错误如下:

        C:\Users\simon\SPA\ANGULAR2 CALENDAR EXAMPLE>npm install

    > node-zopfli@1.4.0 install C:\Users\simon\node_modules\node-zopfli
    > node-pre-gyp install --fallback-to-build

    node-pre-gyp ERR! Tried to download: https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v48-win32-x64.tar.gz
    node-pre-gyp ERR! Pre-built binaries not found for node-zopfli@1.4.0 and node@6.6.0 (node-v48 ABI) (falling back to source compile with node-gyp)
    Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error
     MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK vers
    ion in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Users\simon\
    node_modules\node-zopfli\build\zopfli.vcxproj]
    gyp ERR! build error
    gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Users\simon\node_modules\node-gyp\lib\build.js:276:23)
    gyp ERR! stack     at emitTwo (events.js:106:13)
    gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
    gyp ERR! System Windows_NT 10.0.14393
    gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\simon\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\simon\\node_modules\\node-zopfli\\lib\\binding\\node-v48-win32-x64\\zopfli.node" "--module_name=zopfli" "--module_path=C:\\Users\\simon\\node_modules\\node-zopfli\\lib\\binding\\node-v48-win32-x64"
    gyp ERR! cwd C:\Users\simon\node_modules\node-zopfli
    gyp ERR! node -v v6.6.0
    gyp ERR! node-gyp -v v3.4.0
    gyp ERR! not ok
    node-pre-gyp ERR! build error
    node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\simon\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64' (1)
    node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\simon\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
    node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
    node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
    node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
    node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
    node-pre-gyp ERR! System Windows_NT 10.0.14393
    node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\simon\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
    node-pre-gyp ERR! cwd C:\Users\simon\node_modules\node-zopfli
    node-pre-gyp ERR! node -v v6.6.0
    node-pre-gyp ERR! node-pre-gyp -v v0.6.30
    node-pre-gyp ERR! not ok
    Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\simon\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64' (1)

我在 node.js 6.6.0 和 npm 3.10.3

编辑:

我希望 Luiz 回答...

npm install -g node-gyp

会工作,但不幸的是,安装非常适合健身房..我收到这些错误..如下...

    > node-zopfli@1.4.0 install C:\Users\simon\node_modules\node-zopfli
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download: https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for node-zopfli@1.4.0 and node@6.6.0 (node-v48 ABI) (falling back to source compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and select
ing "Retarget solution". [C:\Users\simon\node_modules\node-zopfli\build\zopfli.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\simon\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\simon\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\simon\\node_modules\\node-zopfli\\lib\\binding\\node-v48-win32-x64\\zopfli.node" "--module_name=zopfli" "--module_path=C:\\Users\\simon\\node_modules\\node-zopfli\\lib\\binding\\node-v48-win32-x64"
gyp ERR! cwd C:\Users\simon\node_modules\node-zopfli
gyp ERR! node -v v6.6.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\simon\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\simon\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 10.0.14393
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\simon\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\simon\node_modules\node-zopfli
node-pre-gyp ERR! node -v v6.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.30
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\simon\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64' (1)
npm WARN install:node-zopfli@1.4.0 node-zopfli@1.4.0 install: `node-pre-gyp install --fallback-to-build`
npm WARN install:node-zopfli@1.4.0 Exit status 1
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\simon\package.json'
npm WARN @ng-bootstrap/ng-bootstrap@1.0.0-alpha.6 requires a peer of @angular/forms@^2.0.0 but none was installed.
npm WARN string-replace-loader@1.0.4 requires a peer of webpack@1.x.x || 2.x.x || 2.x.x-beta but none was installed.
npm WARN simon No description
npm WARN simon No repository field.
npm WARN simon No README data
npm WARN simon No license field.

似乎还有更多问题..还有更多想法

【问题讨论】:

  • 嘿,我更新了我的答案。我忘了提到我在安装 node-gyp 之前所做的一个步骤。

标签: node.js angular npm


【解决方案1】:

我在 windows 上遇到了类似的问题,全局安装 node-gyp 消除了这些错误。

# before installing node-gyp on windows
npm install --global --production windows-build-tools

# install node-gyp globally
npm install -g node-gyp

【讨论】:

  • 我在另一个我想安装的项目上得到了这个,在那个项目上我对 fsevents “npm WARN optional Skipping failed optional dependency /chokidar/fsevents:”的依赖失败了,但是安装了 windows 工具(我有注意到 python 2.7 是我系统上的新安装)和 node-gyp 一样,最后我得到了要创建的 node_modules 文件夹并且我能够运行该应用程序。我仍然无法安装 cli...为 Luiz 添加了 +1
【解决方案2】:

我必须先安装python python.org,你需要使用2.7版本,因为node-gyp不支持更高版本。

所以安装python 2.7,然后npm install -g node-gyp。这对我有用,并且消除了安装 angular-cli 的所有其他错误。

【讨论】:

    【解决方案3】:

    删除package-lock.jsonnode_modules。运行npm install

    【讨论】:

      【解决方案4】:

      使用 mac os,运行此命令有帮助。

      npm --build-from-source install node-pre-gyp
      

      【讨论】:

        【解决方案5】:

        我现在正面临这个问题,经过一些动态设置后,它的工作方式如下

        1. 在终端中使用 bash 命令(zsh 在此处无法正常工作)
        2. 类型:nvm install 12.18.2
        3. 类型:nvm 使用 12.18.2
        4. npm 安装
        5. npm 开始
        6. (宾果游戏...)

        【讨论】:

          【解决方案6】:

          对我来说,代理有问题。所以我在 npm config 中设置了一个无效的 npm 代理值。然后我得到以下输出:

          node-pre-gyp WARN 使用 needle 进行 node-pre-gyp https 下载 node-pre-gyp WARN 下载忽略无效的“代理”配置设置:“0.0.0.0” [bcrypt] 成功:...

          【讨论】:

            【解决方案7】:

            使用旧版本的节点

            对我有用的是使用旧版本的节点。

            例如,我使用节点v14 并使用v12 完成了安装。

            为此,您应该看到this answer

            如果不够,请使用较旧的 python 版本

            如果使用旧版本的node还不够,那么你还应该使用旧的python版本。

            例如,我使用 python v 3.9 并更改为使用 v 2.7 解决了它。

            为此,您应该看到this answer

            【讨论】:

              【解决方案8】:

              我通过键入以下内容解决了这个问题:

               npm install grpc --save
               npm install node-pre-gyp --save
              

              【讨论】:

                【解决方案9】:

                我在运行一个包含sqlite3 包的项目时遇到了这个错误,而且当我运行npm install 时似乎是导致错误的那个。所以,我通过以下方式解决了这个问题:

                1. 删除 package.json 中的 sqlite3
                2. 正在运行npm install
                3. 重新安装 sqlite3,npm install sqlite3

                【讨论】:

                • 非常感谢兄弟,您为我节省了很多时间。
                【解决方案10】:

                对我有用的是将 Node 更新到最新版本。

                【讨论】:

                  【解决方案11】:

                  对我来说,以下工作,

                  1. 从 git (https://github.com/mapbox/node-sqlite3) 以 zip 格式下载包
                  2. 解压压缩包
                  3. npm install --build-from-source --sqlite=/path/to/extracted/folder

                  参考https://www.npmjs.com/package/sqlite3#building-from-the-source

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 2020-06-26
                    • 2015-12-07
                    • 1970-01-01
                    • 2018-12-08
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多