Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npm install not installing because of node-gyp

I'm trying to install the filepreview module with npm. But it always gives error. Here is the error:

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

> [email protected] 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 [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

I've searched for it, generally says it's about node-gyp. My node is v10.16.0. I've also installed Python 2.7. My vs version is 2019.

Is it true that it's only about node-gyp module. If so, is there any other solution to preview a file as png in Node.js

EDIT

I've uninstalled VS2019 and installed VS2017 Build Tools. But still gives another error:

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

> [email protected] 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 [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
like image 616
sundowatch Avatar asked Sep 02 '19 00:09

sundowatch


3 Answers

I have come across this same issue in the past. Here is the solution. You may need to restart your machine several times to clear all the errors.

Solution:

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** 

After this step you have to restart your machine

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

Hope it helps.

like image 146
Ragavan Rajan Avatar answered Oct 19 '22 07:10

Ragavan Rajan


It's node version problem. I'm currently on the latest feature version (Current Version). The newer node is not supported yet. To solve the problem, you could switch to LTS version which is normally fully supported.

Easy switch would be (If you are using brew):

brew unlink node

and then link the node lts verion (right now is node@12) as the following:

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

That solved for me.

like image 3
davychhouk Avatar answered Oct 19 '22 09:10

davychhouk


I am running Windows 11. I followed the steps in the accepted answer, but using the values from this answer on node-gyp GitHub

Can confirm this setup works:

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

Except for me, the msbuild_path was different; my msbuild_path value is:

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

Therefore my steps look like this:

  1. Install VC++ Build Tools (these are installed as part of node's Windows installation (MSI) wizard)
  2. Install Python and add it to your PATH (again this was installed as part of node's wizard)
  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"

Some other answers suggest installing windows-build-tools, which should take care of steps 1 and 2, I don't think this helped me (because node itself installs VS Code and Python), but it might help others (do this step first):

npm install --global windows-build-tools

like image 3
The Red Pea Avatar answered Oct 19 '22 08:10

The Red Pea