Error: Cannot find module 'shrink-ray' - node.js

After using the amazing angular-fullstack-generator though Yeoman, I followed the setup instructions, and when I came to running npm start or gulp serve I got the following error:
Error: Cannot find module 'shrink-ray'
Seemed pretty self-explanitory, so I ran npm install shrink-ray, and doing so gave me the following error:
node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Releas
e/zopfli-v1.4.0-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for node-zopfli#1.4.0 and node#6.9.2 (
node-v48 ABI) (falling back to source compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, pleas
e add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To f
ix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2
005 or 3) add the location of the component to the system path if it is installed el
sewhere. [C:\Users\alicia.sykes\Dropbox\Coding\Angular\team-awesome\node_modules\no
de-zopfli\build\binding.sln]
Again, this error looked pretty self-explanatory, so I followed the steps it suggested - but it didn't work. The same error always returned, preventing me from installing shrink-ray.
After many hours of Googling, it looked like a combination of issues between:
node-gyp
The NPM and node version installed
C++ build tools (why, I have no idea)
Having the Python environmental variable pointing to
the correct installation location of either Python 2.7 or 3.1
Some of these factors modified the error message - but none were the solution.

The solution was in fact simple:
(as admin/sudo) run: npm install --global --production windows-build-tools
This was provided by the very helpful Adonay28 on this GitHub
issue, here:
https://github.com/angular-fullstack/generator-angular-fullstack/issues/2462#issuecomment-275112118
For this to work, you do also need to have:
Python 2.7 or 3.1 installed
The latest version of npm (4.5.0 works). Run: npm i npm -g to update.
And node-gyp installed globally. Run npm install -g node-gyp
Hope this helps someone else, to get there app running quicker thank I did!

Related

How to get node-sqlite3 working on Mac M1?

I'm using Rosetta 2 with Homebrew and have sqlite3 installed.
I added these to my ~/.zshrc so that the node compiler can find the brew installs:
export PATH="/usr/local/opt/sqlite/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/sqlite/lib"
export CPPFLAGS="-I/usr/local/opt/sqlite/include"
I'm using installing using npm install sqlite3, building from source with --build-from-source flag, I'm also specifying the homebrew version of sqlite with --sqlite=/usr/local/opt/sqlite/
node-gyp goes to its fallback build node-pre-gyp install --fallback-to-build
After installation, I'm rebuilding it's native dependencies with electron-builder and install-app-deps
It even rebuilds to the platform and arch I'm looking for, darwin and x64. Which is promising.
• electron-builder version=23.0.3
• loaded parent configuration preset=react-cra
• rebuilding native dependencies dependencies=sqlite3#5.0.8 platform=darwin arch=x64
However, when run the app with npm run dev which runs concurrently " cross-env BROWSER=none npm start" "wait-on http://localhost:3000 && electron ."
It still is trying to find the arm64 version of it:
Error: Cannot find module '[..]/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node'
Even though I can confirm, it did build the x64 version because I have one located at:
/napi-v6-darwin-unknown-x64/node_sqlite3.node
Any help to get this working would be greatly appreciated, thanks!
After 4 days of digging, I have finally gotten it to work!!!
For anyone that might stumble on this:
The reason why sqlite3 won't behave is threefold:
When node sqlite3 is installed using npm install sqlite3, it fetches all dependencies and installs it. It then fetches the precompiled binary binding file for the target arch and platform. In my case we would want napi-v6-darwin-unknown-arm64 for ARM64 and darwin for Apple M1. There is no precompiled binary available yet for this Apple ARM64 and even if there is, the next paragraph will detail why it still won't work.
The problem is that it determines the the system's platform and architecture using the binary compiling package node-pre-gyp and this very savior of a Github issue details how node-pre-gyp is not handling ARM architecture detection properly and basically mixing everything up. Because it's not detecting properly, even if we build our own binding with --build-from-source when installing, it still won't work because it is compiling the wrong binding file for the wrong architecture. To make matters worse, if we don't use --build-from-source, it just simply fetches the Intel precompiled binding file. napi-v6-darwin-unknown-x64
Now for some reason, during runtime, it now detects the architecture properly and tries to look for the ARM64 version of the binding file, it won't find it and will throw the feared error 'module not found' for napi-v6-darwin-unknown-arm64. It obviously won't find it and even if it does, it will throw wrong architecture error because we have the Intel version on board napi-v6-darwin-unknown-x64.
So finally after digging at this for 4 days, here's how I got it working:
Uninstall sqlite3: npm uninstall sqlite3
Install a fresh sqlite3, build it from source, specify the target arch and use fallback build with node-pre-gyp just to be safe: npm install sqlite3 --build-from-source --target_arch=arm64 --fallback-to-build
Now the correct binding file is compiled for the correct platform and architecture, on runtime it will find it and will run!

Error while installing quick.db in discord.js

This is my error. I constantly keep getting this error while trying to npm install quick.db
I am using Visual Studio Code, Node version 17.0.0, discord.js version 13.3.1, please help me, any help would be appreciated.
See the installation section of quick.db
Troubleshooting quick.db/better-sqlite3 installation
Make sure you're using nodejs v10.20.1 or later
Make sure you have node-gyp globally installed, including all of its dependencies. On Windows you may need to configure some things manually. Use npm ls node-gyp to make sure none of your local packages installed an outdated version of node-gyp that is used over the global one.
If you're using Electron, try running electron-rebuild
If you're using Windows, follow these steps. Do them in this order, and don't skip steps.
Install the latest of node 10, 12, or 14.
Install latest Visual Studio Community and Desktop Development with C++ extension.
Install latest Python.
Run following commands:
npm config set msvs_version 2019
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"
Run npm install quick.db

How must a development environment be set up to build prestashop theme assets?

I'm trying to build the Prestashop classic theme's assets, according to Prestashop's documentation. I'm on Windows 10, using cygwin. Here is what I did in detail:
I forked the latest stable tag (1.7.6.7).
I ran ./tools/assets/build.sh in cygwin. (I also tried in Windows Terminal and step by step, i.e. cd theme dir, followed by npm install.)
npm install threw an error complaining about missing Python.
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
I installed Python 3 and got an error complaining about missing Python 2.7
I installed Python 2.7 and got an error complaining about missing Visual Studio 2008.
Projet "E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln" sur le noud 1 (cibles par défaut).
ValidateSolutionConfiguration:
Génération de la configuration de solution "Release|x64".
MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft
Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008.
[E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln]
Génération du projet "E:\xampp\htdocs\prestashop\themes\classic\_dev\node_modules\node-sass\build\binding.sln"
terminée (cibles par défaut) -- ÉCHEC.
Before I continue on a trial and error basis, I'd like to ask if someone knows what prerequisites are needed to set up a complete development environment for Prestashop themes. Or more precisely, what is the list of software I must install before being able to run npm install?
https://devdocs.prestashop.com/ clearly doesn't give any clue, they only explain installation of npm and composer here.
How to set up a Prestashop development environment?
The answer was not straight forward:
The theme uses node-sass, which is compiled using node-gyp.
As the readme of node-gyp states, on Windows we need to install npm install --global --production windows-build-tools, which takes care of Python and Visual Studio.
The theme of the latest stable release of Prestashop 1.7.6.7 uses a node-sass version (^4.11.0), which is not compatible with node 12.x
Therefore, we need to install nvm for windows and use the latest version of the node 10.x branch.
With these steps, npm install will work.
npm run build will fail, because the npm script is not compatible with Windows.
In stead of npm run build (which calls NODE_ENV=production webpack --progress --colors --debug --display-chunks), we have to run
set NODE_ENV=production
npx webpack --progress --colors --debug --display-chunks
It looks like the Devs of Prestashop never tried to get their work running on Windows.
Classic theme uses webpack to compile assets, more informations:
https://devdocs.prestashop.com/1.7/development/compile-assets/
Best way is to navigate to themes/classic/_dev and run npm install :) later you can use npm run watch or npm run build or any other defined script

npm install on mingw

Introduction
I want to install aglio with npm on Windows:
npm install -g aglio
It fails when node-gyp rebuild, complaining MSB3428.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
The error message instructs me to install Visual Studio.
Question
Can I install aglio (or any other packages involving node-gyp) without installing VisualStudio?
(My computer has scarce storage.)
Preferably, I want to make use of MinGW.
(Configuring GYP_GENERATOR would solve the problem?)

npm install jsdom error on windows?

I have installed nodejs on my windows pc. And it was working fine. But when I tried to install jsdom using
"npm install jsdom" I was prompoted by this error.
node "C:\Program
Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js"
rebuild info it
worked if it ends with ok
ERR! Error: Python does not seem to be installed
at failNoPython (C:\Program
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:78:14)
at Object.oncomplete (C:\Program
Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:66:11)
ERR! not ok
npm WARN optional dependency failed, continuing contextify#0.1.2
jsdom#0.2.13 ./node_modules/jsdom
+-- cssom#0.2.3 +-- htmlparser#1.7.5
Can anyone help me regarding this problem?
I had the same issue on Windows 7 (x64 Ultimate), after hours of search and trials, here is how I resolved it. Please follow the steps in the same exact order:
Install Visual Studio 2010/2012 C++ (Express or higher)
Install Windows SDK 7.1
Install "Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1"
Install GTK (C:\GTK)
Install Python (C:\Python27)
Install node.js (x86)
Add [node.js] to path (C:\Program Files (x86)\nodejs\;)
Add [python] to path (C:\Python27\;)
Add [GTK] to path (C:\GTK\bin;)
Add [WindowsSDKDir] System Variable pointing to "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin"
Run "Windows SDK 7.1 Command Prompt" as Administrator
Set environment to x86 using "setenv /x86"
Change directory to "C:\Program Files (x86)\nodejs\"
Run "npm install -g npm"
Run "npm update -g npm"
Run "npm install -g node-gyp"
Run "node-gyp configure build"
Run "npm install jsdom"
Run "npm install ajax"
Run "npm install http-server"
Run "npm install jquery"
Run "npm install xmlhttprequest"
Run "npm update"
I hope this helps.
There is a nice guide to getting JSDom working on Windows here: http://www.steveworkman.com/node-js/2012/installing-jsdom-on-windows/
jsdom has a dependency on contextify, which only recently supports windows. You'll need python and a C++ compiler to install it.
You may also need to do the following
npm install -g node-gyp
node-gyp configure
For windows 8 64-bit, installing zmq and protobuf, the following worked for me:
First, Install Visual Studio 2012
Then, on the command prompt (in your project directory):
SET VisualStudioVersion=11.0
npm install zmq
npm install protobuf
npm install jsdom
jsdom uses contextify for running JavaScript on the DOM. And contextify requires native C++ compiler. According to the official readme, on Windows platform, one has to install:
A recent copy of the x86 version of Node.js for Windows, not the x64 version. (should be okay by default)
A copy of Visual C++ 2010 Express. (or any newer version)
A copy of Python 2.7, installed in the default location of C:\Python27.
If you have python installed already, you would need to add the python install directory to the PATH environment variable.
Assuming that python.exe is in the C:\Python32\ directory, on the DOS prompt you need to type:
set PATH=%PATH%;C:\Python32\;
and then:
node-gyp configure
should work fine without that error.
After almost a half year of solving this issue, reading all forums related to this, I finally found the solution.
What I did was simple in my case because I don't use many apps on this computer.
My Windows 8.1 had many programs installed which confused the NodeJS probably (Frameworks, VS addons, etc.).
So I simply did this:
Removed all programs from MS, that I installed once.
Uninstalled Nodejs
For sure I cleaned the registry with CCleaner
Removed Python, Node-gyp and other apps related to Node.js
Then I reinstalled Node.js with optimism for JSdom which installed correctly, but crashed while running my project. So I searched for the new error which - again - has a simple solution. I had to install an older version of JSdom.
npm install jsdom#4.2.0
Finally, everything works. Hope that helps anyone with this issue.

Resources