I have a lots of errors when I want to install webpack. My version of node is: v14.17.0 version of npm: 7.13.0 Im on windows 10
Here are the errors:
npm ERR! code 1
npm ERR! path D:\LocalSites\fundraise-better\app\public\wp-content\themes\fundraisebetter\node_modules\fibers
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node build.js || nodejs build.js
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | ia32
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Python39\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack File "<string>", line 1
npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack at ChildProcess.exithandler (child_process.js:319:12)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:376:20)
npm ERR! gyp ERR! stack at maybeClose (internal/child_process.js:1055:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19041
npm ERR! gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "D:\\LocalSites\\fundraise-better\\app\\public\\wp-content\\themes\\fundraisebetter\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd D:\LocalSites\fundraise-better\app\public\wp-content\themes\fundraisebetter\node_modules\fibers
npm ERR! gyp ERR! node -v v14.17.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! node-gyp exited with code: 1
npm ERR! Please make sure you are using a supported platform and node version. If you
npm ERR! would like to compile fibers on this machine please make sure you have setup your
npm ERR! build environment--
npm ERR! Windows + OS X instructions here: https://github.com/nodejs/node-gyp
npm ERR! Ubuntu users please run: `sudo apt-get install g++ build-essential`
npm ERR! RHEL users please run: `yum install gcc-c++` and `yum groupinstall 'Development Tools'`
npm ERR! Alpine users please run: `sudo apk add python make g++`
npm ERR! 'nodejs' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm timing npm Completed in 240044ms
The problem is a native module problem! It's a common problem!
A native module is a module that have a binding to a native program and binaries! For example a c++ project! Therefor project build and compilation is needed! For this most packages use node-gyp!
The problem is simple! You have a problem where your environment is missing the necessary build and compilation tools!
If you check the error message well! It's all said!
So depending on what platform you are! Linux, macos or windows! Follow the instruction above!
You can simply go and check https://github.com/nodejs/node-gyp to see the different instruction!
Python is required in all platforms! (Node-gyp use python heavily that's why)
In linux gcc is used! (check the message error above! For instruction)
"
debian based:
sudo apt-get install g++ build-essential
,Redhat and fedora:
yum install gcc-c++
andyum groupinstall 'Development Tools'
Any other destribution search for the equivalent! I never fell in such problem in linux! As most distribution have it all!
"
In windows visual studio build tools are needed
https://github.com/nodejs/node-gyp#on-windows
In macos clang is used! And xcode need to have clang!
https://github.com/nodejs/node-gyp#on-macos
Check the node-gyp doc!
Steps from doc
On macOS
ATTENTION: If your Mac has been upgraded to macOS Catalina (10.15), please read macOS_Catalina.md.
You also need to install the XCode Command Line Tools by running xcode-select --install. Alternatively, if you already have the full Xcode installed, you can find them under the menu Xcode -> Open Developer Tool -> More Developer Tools.... This step will install clang, clang++, and make.
On Windows
Install the current version of Python from the Microsoft Store package.
Install tools and configuration manually:
Install Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio Community (using the "Desktop development with C++" workload) Launch cmd,
Big important!
If the above steps didn't work for you, please visit Microsoft's Node.js Guidelines for Windows for additional tips.
To target native ARM64 Node.js on Windows 10 on ARM, add the components "Visual C++ compilers and libraries for ARM64" and "Visual C++ ATL for ARM64".
Once downloading the build tools installer from the link above! Or from the download page here
The tool go like this
You can check vscode doc too for c++: https://code.visualstudio.com/docs/cpp/config-msvc
All is needed is to install c++ build tools! And the right elements!
You can check Installing MS C++ 14.0 for python without Visual Studio too for extra sense!
And the easy tool
On windows this article both give good explanation and an easy way for the setup
https://spin.atomicobject.com/2018/06/18/windows-node-js/
(if you haven't gone with the scoop package command way! Then just remove sudo and run it on a console that have Admin rights!
From windows-build-tools package doc!
Both installations are conflict-free, meaning that they do not mess with existing installations of Visual Studio, C++ Build Tools, or Python. If you see anything that indicates otherwise, please file a bug.
VS 2017 or 2015
VS 2019
As by node-gyp doc! And guide! They are suggesting vs 2017
Most packages use vs 2015 or 2017! 2017 Should do well! If you get any problems for some reason! Install them both!
Also if VS 2019 is needed at any time and any reason! One can go with the manual way stated above!
and use
npm config set msvs_version 2019
One can always use that for version change! When it comes to npm!
Well it's a thing that you may never need to care about! But just in case!
packages with native modules that may have complications! Generally they will state how to go about the build tools! If there is any!