由于 node-gyp,Npm install 未安装

Posted

技术标签:

【中文标题】由于 node-gyp,Npm install 未安装【英文标题】:Npm install not installing because of node-gyp 【发布时间】:2020-01-05 02:23:45 【问题描述】:

我正在尝试使用npm 安装filepreview 模块。但它总是给出错误。这是错误:

D:\Program Files\nodejs\PalettenzettelGenerator>npm install filepreview

> fibers@1.0.15 install D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers
> node build.js || nodejs build.js


D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers>if not defined npm_config_node_gyp (node "D:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release )  else (node "D:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild --release )
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:415:16)
gyp ERR! stack     at process._tickCallback (internal/process/next_tick.js:63:19)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
node-gyp exited with code: 7
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
Alpine users please run: `sudo apk add python make g++`
'nodejs' is not recognized as an internal or external command,
operable program or batch file.
npm WARN PalettenzettelGenerator@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fibers@1.0.15 install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fibers@1.0.15 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ibrahim\AppData\Roaming\npm-cache\_logs\2019-09-02T08_17_55_828Z-debug.log

我已经搜索过了,一般说是node-gyp。我的节点是 v10.16.0。我还安装了 Python 2.7。我的vs版本是2019。

真的只是关于node-gyp 模块。如果是这样,是否有任何其他解决方案可以在 Node.js 中将文件预览为 png

编辑

我已经卸载了 VS2019 并安装了 VS2017 构建工具。但仍然给出另一个错误:

D:\Program Files\nodejs\PalettenzettelGenerator>npm install filepreview

> fibers@1.0.15 install D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers
> node build.js || nodejs build.js


D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers>if not defined npm_config_node_gyp (node "D:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release )  else (node "D:\Program Files\nodejs\node_modules\node-gyp\bin\node-gyp.js" rebuild --release )
Bu çözümde projeler tek tek derlenir. Paralel bir derlemeyi etkinleştirmek için lütfen "/m" anahtarını ekleyin.
  fibers.cc
  coroutine.cc
  win_delay_load_hook.cc
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(122): error C2660: 'v8::String::NewFromOneByte': işlev 2 bağımsız değişken almıyor [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\
fibers\build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(2802): note: 'v8::String::NewFromOneByte' bildirimine bakın (kaynak dosyası derleniyor ..\src\fibers.cc)
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(126): error C2660: 'v8::String::NewFromOneByte': işlev 2 bağımsız değişken almıyor [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\
fibers\build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(2802): note: 'v8::String::NewFromOneByte' bildirimine bakın (kaynak dosyası derleniyor ..\src\fibers.cc)
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(406): warning C4996: 'v8::String::Utf8Value::Utf8Value': kullanım dışı olarak bildirildi [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_mo
dules\fibers\build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(2891): note: 'v8::String::Utf8Value::Utf8Value' bildirimine bakın
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(433): error C2661: 'v8::Function::NewInstance': hiçbir aşırı yüklenmiş işlev 2 bağımsız değişken almaz [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synch
ronize\node_modules\fibers\build\fibers.vcxproj]
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(433): error C2672: 'uni::Return': eşleşen aşırı yüklenmiş işlev bulunamadı [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers\b
uild\fibers.vcxproj]
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(621): error C2512: 'v8::TryCatch': kullanılabilir uygun varsayılan oluşturucu yok [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\f
ibers\build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(8529): note: 'v8::TryCatch' bildirimine bakın (kaynak dosyası derleniyor ..\src\fibers.cc)
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(628): warning C4996: 'v8::Script::Compile': kullanım dışı olarak bildirildi [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers\
build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(1255): note: 'v8::Script::Compile' bildirimine bakın
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(643): warning C4996: 'v8::TryCatch::StackTrace': kullanım dışı olarak bildirildi [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fi
bers\build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(8593): note: 'v8::TryCatch::StackTrace' bildirimine bakın
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(741): error C2661: 'v8::Value::ToNumber': hiçbir aşırı yüklenmiş işlev 0 bağımsız değişken almaz [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize
\node_modules\fibers\build\fibers.vcxproj]
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(793): error C2660: 'v8::Object::SetAccessor': işlev 2 bağımsız değişken almıyor [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fib
ers\build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(3348): note: 'v8::Object::SetAccessor' bildirimine bakın (kaynak dosyası derleniyor ..\src\fibers.cc)
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(794): error C2664: 'v8::Maybe<bool> v8::Object::SetAccessor(v8::Local<v8::Context>,v8::Local<v8::Name>,v8::AccessorNameGetterCallback,v8::AccessorNameSetterCallback,v8::M
aybeLocal<v8::Value>,v8::AccessControl,v8::PropertyAttribute,v8::SideEffectType)' : 2 bağımsız değişkeni 'uni::FunctionType (__cdecl *)(v8::Local<v8::String>,const uni::GetterCallbackInfo &)' değerinden 'v8::Local<v8::Name>' değerine dönüştürülemez [D:\Program Files\nodejs\Pal
ettenzettelGenerator\node_modules\synchronize\node_modules\fibers\build\fibers.vcxproj]
  d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(794): note: Kaynak türünü hiçbir oluşturucu alamadı veya oluşturucu aşırı yük çözümü belirsizdi
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\fibers.cc(795): error C2660: 'v8::Object::SetAccessor': işlev 2 bağımsız değişken almıyor [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fib
ers\build\fibers.vcxproj]
  c:\users\ibrahim\appdata\local\node-gyp\cache\10.16.0\include\node\v8.h(3348): note: 'v8::Object::SetAccessor' bildirimine bakın (kaynak dosyası derleniyor ..\src\fibers.cc)
d:\program files\nodejs\palettenzettelgenerator\node_modules\synchronize\node_modules\fibers\src\coroutine.cc(138): warning C4552: '!': ifade sonucu kullanılmıyor [D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers\build\fibers.vcxproj
]
gyp ERR! build error
gyp ERR! stack Error: `D:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:\Program Files\nodejs\node_modules\node-gyp\lib\build.js:196:23)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd D:\Program Files\nodejs\PalettenzettelGenerator\node_modules\synchronize\node_modules\fibers
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
Alpine users please run: `sudo apk add python make g++`
'nodejs' is not recognized as an internal or external command,
operable program or batch file.
npm WARN PalettenzettelGenerator@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fibers@1.0.15 install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fibers@1.0.15 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ibrahim\AppData\Roaming\npm-cache\_logs\2019-09-02T23_04_29_295Z-debug.log

【问题讨论】:

如果您搜索了 node-gyp 问题跟踪器或 google,您可能会发现(出于没有人理解,包括您和我在内的原因)只有 node-gyp适用于 python 2.7 - 但查看您的错误日志。 我也安装了 python 2.7,它仍然给出 node-gyp 错误 你设置npm configs了吗? 当我通过'python -V'查看python版本时,版本是2.7.16。我也设置了配置 所以,让我们继续阅读日志。 gyp ERR! stack Error: spawn D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe ENOENT 说 MSBuild.exe 在您的 path/env/etc 建议它应该存在的地方不存在。你修好了吗?另外,您是否按照日志告诉您的方式访问了github.com/nodejs/node-gyp,以查看这是否是一个已知问题,或者甚至是具有记录解决方案的记录事件? 【参考方案1】:

我过去也遇到过同样的问题。这是解决方案。您可能需要多次重新启动机器以清除所有错误。

解决办法:

1. Install Install VC++ Build Tools  2017 and while installing select V140 from the side menu

2. Install Python 2.7, and add it to your PATH

3. npm config set python python2.7 --global

4. npm config set python C:\Python27\python.exe --global

5. npm config set msvs_version 2015 --global

6. set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140


**Note:  If you still face error > most likely the problem is node-sass is not installed** 

这一步之后你必须重启你的机器

7. Install the latest versions of Python

8. As Admin:
$ cd "C:\Program Files\nodejs\node_modules\npm"
$ npm install node-gyp

9. $ npm config set msvs_version 2015 --global

Note: that I have VS 2017, but configuring it as ver 2017 won't work. Not sure why.

    10. As Admin:
$ npm install -g node-sass

And finally, one last check:
$ node-sass -v

希望对您有所帮助。

【讨论】:

正如@ragavan-rajan 所说,当我进行配置并安装与npm install https://github.com/alexeypetrushin/synchronize.git 同步时,文件预览已成功安装。谢谢。 很高兴它有帮助。 嗨@RagavanRajan,尝试了这些步骤,但没有奏效。这里我有更多细节:***.com/questions/64578469/… 嗨@Andres,您能否确认您的机器上的第 1 步是什么。看起来你安装了不同版本的 VC++。 我确信这就是问题所在。不过会等你的回复【参考方案2】:

是节点版本问题。我目前在latest feature version (Current Version)。尚不支持较新的节点。 要解决此问题,您可以切换到通常完全支持的LTS version。

简单的切换是(如果您使用的是brew):

brew unlink node

然后链接node lts verion(现在是node@12)如下:

brew install node@12 && brew link --overwrite node@12 --force

这为我解决了。

【讨论】:

【参考方案3】:

对我有用的简单解决方法是:

我安装了 Python 3.7 并从 https://my.visualstudio.com/Downloads?q=visual%20studio%202017 安装了 Visual Studio 2017 版

还安装了推荐的更新。

然后我设置 npm config set msvs_version 2017 --global。

【讨论】:

【参考方案4】:

花了3天多终于在https://spin.atomicobject.com/2019/03/27/node-gyp-windows/找到了解决办法

当我运行“npm install -no-optional”时它起作用了 -no-optional 标志确保 npm 只安装所需的包。

快速说明:我按照https://github.com/nodejs/node-gyp#on-windows 中列出的所有步骤,最后运行“npm install -no-optional”

【讨论】:

【参考方案5】:

我正在运行 Windows 11。我关注 the steps in the accepted answer,但使用来自此 answer on node-gyp GitHub 的值

可以确认此设置有效:

msbuild_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
msvs_version = "2017"

除了我,msbuild_path 不一样;我的msbuild_path 值是:

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe

因此我的步骤如下:

    安装 VC++ 构建工具(这些工具作为node's Windows installation (MSI) wizard 的一部分安装) 安装 Python 并将其添加到您的 PATH(再次作为节点向导的一部分安装) npm config set python python2.7 --global npm config set python C:\Python27\python.exe --global npm config set msvs_version 2017 --global npm config set msbuild_path "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe"

一些other answers 建议安装windows-build-tools,它应该负责第1 步和第2 步,我认为这对我没有帮助(因为节点本身 安装了VS Code 和Python),但是它可能会帮助其他人(先执行此步骤):

npm install --global windows-build-tools

【讨论】:

【参考方案6】:

我关闭了 npm 包的 Visual Studio 自动更新

【讨论】:

【参考方案7】:

这是节点版本问题。 就我而言,我试图使用不兼容的 Node 版本 14 安装 node-sass:4.13.0。 我卸载了 Node14,清除了 npm 缓存,并使用 Chocolately 安装了 Node 12.8 版本。这解决了我的问题。

【讨论】:

【参考方案8】:

在尝试了许多解决方案(包括接受的答案)后,对我来说这是一个非常简单的解决方案。

我从我正在处理的项目的package.json 中删除了node-sass 并重新安装。

【讨论】:

【参考方案9】:

解决方案:“gyp ERR! stack Error: spawn D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe ENOENT”

    npm install --global windows-build-tools

                      OR
    

    npm --vs2017 install --global windows-build-tools(在admin power shell中)

    如果成功,请等待 cmd 上显示“All done!”消息

    安装 Python 2.7 https://www.python.org/downloads/release/python-275/

    npm config set python python2.7 --global

    npm config set python C:\Python27\python.exe --global

    npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"

    注意:请检查您的构建工具 2017 路径位置

    (Visual Studio 构建工具 2017)

    npm 安装

谢谢,

病毒性卡拉里亚

【讨论】:

【参考方案10】:

设置 MSBuild 路径对我有用。它无法识别我的 VS2019 MSbuild 路径。

npm 配置设置 msvs_version 2017 npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe"

【讨论】:

已经有一个接受的答案,它建议对您的建议进行类似的配置更改。请注意,接受的答案还谈到了 MSBuild:6. set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140

以上是关于由于 node-gyp,Npm install 未安装的主要内容,如果未能解决你的问题,请参考以下文章

npm install时node-gyp报错

npm install 并在 node-gyp 重建时失败,使用 ``gyp: No Xcode or CLT version detected!``` 由新的 macos catalina 更新引起

npm install 时卡在了node-gyp rebuild

需要 node-gyp 的 npm install 在 Windows 上失败

npm install jquery 在 node-gyp 重建时失败

Windows npm install node-gyp 错误:libxslt 命令失败