簡體   English   中英

Npm 安裝由於 node-gyp 而未安裝

[英]Npm install not installing because of node-gyp

我正在嘗試使用filepreview安裝npm預覽模塊。 但它總是給出錯誤。 這是錯誤:

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 Build Tools。 但仍然給出另一個錯誤:

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

我過去遇到過同樣的問題。 這是解決方案。 您可能需要多次重新啟動計算機才能清除所有錯誤。

解決方案:

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

希望能幫助到你。

是節點版本問題。 我目前使用的是最新功能版本 (Current Version) 尚不支持較新的節點。 要解決此問題,您可以切換到通常完全支持的LTS 版本

輕松切換將是(如果您使用brew ):

brew unlink node

然后將節點 lts verion (現在是 node@12)鏈接如下:

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

那為我解決了。

我關閉了視覺工作室的 npm 包的自動更新

對我有用的簡單修復是:

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

還安裝了推薦的更新。

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

花了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”

是節點版本問題。 就我而言,我試圖安裝 node-sass:4.13.0 與不兼容的 Node 版本 14。 我卸載了 Node14,清除了 npm 緩存,並使用 Chocolately 安裝了 Node 12.8 版本。 這解決了我的問題。

我正在運行 Windows 11 並且我有 . 我按照已接受的答案中的步驟進行操作,但在 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

因此,我的步驟如下所示:

  1. 安裝 VC++ 構建工具(這些作為節點的 Windows 安裝 (MSI) 向導的一部分安裝
  2. 安裝 Python 並將其添加到您的 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 2017 --global
  6. npm config set msbuild_path "C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\2019\\\\BuildTools\\\\MSBuild\\\\Current\\\\Bin\\\\MSBuild.exe"

其他一些答案建議安裝windows-build-tools ,它應該處理第 1 步和第 2 步,我認為這對我沒有幫助(因為 node本身安裝了 VS Code 和 Python),但它可能會幫助其他人(先執行此步驟):

npm install --global windows-build-tools

在嘗試了許多解決方案后,包括接受的答案,對我來說這是一個非常簡單的解決方案。

我從我正在處理的項目的package.json中刪除了node-sass並重新安裝。

解決方案: “gyp ERR!堆棧錯誤:生成 D:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\15.0\\Bin\\MSBuild.exe ENOENT”

  1. npm --vs2015 install --global windows-build-tools (在管理電源外殼中

    如果成功,請等待“全部完成! ”消息顯示在cmd上

  2. 安裝 Python 2.7並將其添加到您的 PATH https://www.python.org/downloads/release/python-275/

  3. npm 配置集 python python2.7 --global

  4. npm 配置集 python C:\\Python27\\python.exe --global

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

    注意:請檢查您的構建工具 2017 路徑位置

    (Visual Studio 構建工具 2017)

  6. 安裝

謝謝,

病毒性瘧原蟲

對於Visual Studio 2022VCTargetsPath必須設置為C:\Program Files\Microsoft Visual Studio\2022\<EDITION>\MSBuild\Microsoft\VC\v170\

<EDITION>更改為您正在運行的 VS 版本(例如ProfessionalCommunity )。

我也這樣做了。 我仍然收到錯誤。 有沒有人可以幫忙

  • npm -v = 6.10.3
  • 節點 -v = v12.10.0
  • 蟒蛇 -V = 蟒蛇 2.7.16
  • node-sass -v =(第一行) node-sass 4.12.0 (Wrapper) [JavaScript]
  • node-sass -v =(第二行) libsass 3.5.4 (Sass 編譯器) [C/C++]
  • 節點-gyp -v = v5.0.3

錯誤信息

gyp verb node dev dir C:\Users\_UserName_\.node-gyp\12.10.0
gyp verb found first Solution file build/binding.sln
gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 9/19/2019 3:43:05 PM.
Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Release|x64".
Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" (1) is building "C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) on node 1 (default targets).
Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (2) is building "C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj" (3) on node 1 (default targets).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj]
Done Building Project "C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (default targets) -- FAILED.
Done Building Project "C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" (default targets) -- FAILED.

Build FAILED.

"C:\_ProjectPath_\node_modules\node-sass\build\binding.sln" (default target) (1) ->
"C:\_ProjectPath_\node_modules\node-sass\build\binding.vcxproj.metaproj" (default target) (2) ->
"C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj" (default target) (3) ->
(PlatformPrepareForBuild target) ->
  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\_ProjectPath_\node_modules\node-sass\build\src\libsass.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.37
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\_ProjectPath_\node_modules\node-sass\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\_ProjectPath_\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\_ProjectPath_\node_modules\node-sass
gyp ERR! node -v v12.10.0
gyp ERR! node-gyp -v v3.8.0

設置 MSBuild 路徑對我有用。 它無法識別我的 VS2019 MSbuild 路徑。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM