Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
644 views
in Technique[技术] by (71.8m points)

javascript - 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
odejsPalettenzettelGenerator>npm install filepreview

> [email protected] install D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers
> node build.js || nodejs build.js


D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers>if not defined npm_config_node_gyp (node "D:Program Files
odejs
ode_modules
pm
ode_modules
pm-lifecycle
ode-gyp-bin\....
ode_modules
ode-gypin
ode-gyp.js" rebuild --release )  else (node "D:Program Files
odejs
ode_modules
pm
ode_modules
ode-gypin
ode-gyp.js" rebuild --release )
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn D:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuild15.0BinMSBuild.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
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers
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:UsersibrahimAppDataRoaming
pm-cache\_logs2019-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
odejsPalettenzettelGenerator>npm install filepreview

> [email protected] install D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers
> node build.js || nodejs build.js


D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers>if not defined npm_config_node_gyp (node "D:Program Files
odejs
ode_modules
pm
ode_modules
pm-lifecycle
ode-gyp-bin\....
ode_modules
ode-gypin
ode-gyp.js" rebuild --release )  else (node "D:Program Files
odejs
ode_modules
ode-gypin
ode-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
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(122): error C2660: 'v8::String::NewFromOneByte': i?lev 2 ba??ms?z de?i?ken alm?yor [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modules
fibersuildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(2802): note: 'v8::String::NewFromOneByte' bildirimine bak?n (kaynak dosyas? derleniyor ..srcfibers.cc)
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(126): error C2660: 'v8::String::NewFromOneByte': i?lev 2 ba??ms?z de?i?ken alm?yor [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modules
fibersuildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(2802): note: 'v8::String::NewFromOneByte' bildirimine bak?n (kaynak dosyas? derleniyor ..srcfibers.cc)
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(406): warning C4996: 'v8::String::Utf8Value::Utf8Value': kullan?m d??? olarak bildirildi [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_mo
dulesfibersuildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(2891): note: 'v8::String::Utf8Value::Utf8Value' bildirimine bak?n
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.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
odejsPalettenzettelGenerator
ode_modulessynch
ronize
ode_modulesfibersuildfibers.vcxproj]
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(433): error C2672: 'uni::Return': e?le?en a??r? yüklenmi? i?lev bulunamad? [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers
uildfibers.vcxproj]
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(621): error C2512: 'v8::TryCatch': kullan?labilir uygun varsay?lan olu?turucu yok [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesf
ibersuildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(8529): note: 'v8::TryCatch' bildirimine bak?n (kaynak dosyas? derleniyor ..srcfibers.cc)
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(628): warning C4996: 'v8::Script::Compile': kullan?m d??? olarak bildirildi [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers
buildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(1255): note: 'v8::Script::Compile' bildirimine bak?n
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(643): warning C4996: 'v8::TryCatch::StackTrace': kullan?m d??? olarak bildirildi [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfi
bersuildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(8593): note: 'v8::TryCatch::StackTrace' bildirimine bak?n
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.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
odejsPalettenzettelGenerator
ode_modulessynchronize

ode_modulesfibersuildfibers.vcxproj]
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(793): error C2660: 'v8::Object::SetAccessor': i?lev 2 ba??ms?z de?i?ken alm?yor [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfib
ersuildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(3348): note: 'v8::Object::SetAccessor' bildirimine bak?n (kaynak dosyas? derleniyor ..srcfibers.cc)
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.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
odejsPal
ettenzettelGenerator
ode_modulessynchronize
ode_modulesfibersuildfibers.vcxproj]
  d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.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
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrcfibers.cc(795): error C2660: 'v8::Object::SetAccessor': i?lev 2 ba??ms?z de?i?ken alm?yor [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfib
ersuildfibers.vcxproj]
  c:usersibrahimappdatalocal
ode-gypcache10.16.0include
odev8.h(3348): note: 'v8::Object::SetAccessor' bildirimine bak?n (kaynak dosyas? derleniyor ..srcfibers.cc)
d:program files
odejspalettenzettelgenerator
ode_modulessynchronize
ode_modulesfiberssrccoroutine.cc(138): warning C4552: '!': ifade sonucu kullan?lm?yor [D:Program Files
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibersuildfibers.vcxproj
]
gyp ERR! build error
gyp ERR! stack Error: `D:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0BinMSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (D:Program Files
odejs
ode_modules
ode-gyplibuild.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
odejsPalettenzettelGenerator
ode_modulessynchronize
ode_modulesfibers
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:UsersibrahimAppDataRoaming
pm-cache\_logs2019-09-02T23_04_29_295Z-debug.log
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:Python27python.exe --global

5. npm config set msvs_version 2015 --global

6. set VCTargetsPath=C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140


**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
odejs
ode_modules
pm"
$ 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...