Unable to install node.js package 'scrypt' using npm on windows - node.js

Installing scrypt using npm on windows is giving following error.
The build is failing due to node-gyp

From github documentation node-Gyp is listed as pre-requisite as it is required to build scrypt. Make it sure to install node-Gyp
using npm install -g node-gyp
For successfull working of this plugin you will also need to install all the required tools and configurations using Microsoft's windows-build-tools
using npm install --global --production windows-build-tools
from an elevated PowerShell or CMD.exe (run as Administrator).
for other options and alternatives follow node-gyp documentation
Before installing scrypt
Follow installation instructions given at github

For NodeJS 10.5.0 and higher
My answer could be a little bit out of topic, but I encountered a similar error with the installation of the scrypt library for NodeJS v12: during the compilation of the C/C++ modules with node-gyp a lot of compiling warnings and errors appear.
Though, there is an elegant solution.
Since version 10.5.0 NodeJS has a crypto.scrypt(...) function, which (with several other functions from crypto module) could cover almost all real use-cases.
So, a decent solution could sound like: Remove scrypt-package from your code and use the appropriate functions from the crypto-native module.
Sadly, but in most cases it is not the best solution for a real business

first you need to install windows-build-tools
run this command first
> npm install --global --production windows-build-tools

Related

Installing --global windows-build-tools never completes

I am trying to install --global windows-build-tools by running below command
npm install --global windows-build-tools -verbose
No matter if I try through PowerShell or CMD (both as Administrator), the installation gets stuck in the same step.
npm info run windows-build-tools#5.2.2 postinstall node_modules/windows-build-tools node ./dist/index.js
[##################] | reify:resolve: info run windows-build-tools#5.2.2 postinstall node_modules/windows-build-tools node ./dist/index.js
Is there a reason why this might not complete?
According to the windows-build-tools repo
Please note that the official Node.js for Windows installer can now
automatically install the required tools. That's likely a much better
option than the module listed here (windows-build-tools).
recommended approach:
Go to node-download-page
Download LTS version for windows
Follow the installation instructions
When you got to this window, check the checkbox
After the installation it will prompt you to this window, it will automatically download the necessary dependencies
If you want to use this package(not recommended):
You should try to roll back to version 4.0.0
Run the command-line as administrator and try this:
npm install --global windows-build-tools#4.0.0
related question
If you're having trouble installing windows-build-tools (which I had a problem with recently), you should roll back to version 4.0.0.
Run PowerShell as Administrator, and then type in the following command (assuming you have node and npm installed).
npm install --global windows-build-tools#4.0.0
This process can take some time, so please be patient.
Built-in Node.js Build Tools
There are built-in Node.js build tools, so it is recommended to use this. In fact, if you go on the npm or GitHub page of the windows-build-tools package, it will say that you should use the Node.js build tools.
To do this, go to the official Node.js download website, and download the LTS version. Then, run the installer. At a point in the installation, it will have a checkbox that says Automatically install the recommended tools. Make sure to check that!
When you install it, it will also install Chocolatey, and install the build tools like the windows-build-tools package.
Even though both of these work, it is recommended to use the Node.js built tools!
Following this thread for a while now.
Disclaimer: Please note that I know this is not directly answering your question about why the process gets stuck but I want to share my solution anyway.
The installation via chocolatey did not work for me, as mentioned in:
https://github.com/felixrieseberg/windows-build-tools/issues/245
https://github.com/felixrieseberg/windows-build-tools/issues/152
Then, I found this microsoft page. On this page, the person asked this question:
I tried to install the Microsoft Visual C++ Build tools. The installer
(filename is visualcppbuildtools_full.exe) stops right after the start
of the installation it says a setup package is missing or damaged("Ein
Setuppaket fehlt oder ist beschädigt"). The option to download it
again doesnt work. Downloading the installer again doesnt help. Trying
to do an offline installation doesnt work either and I get the same
error. How can I find out what exactly the problem is and how can I
solve it?
The solution mentions the page https://my.visualstudio.com/Download that provides different build tool versions:
I was able to download and install "Build Tools for Visual Studio 2017 (version 15.9)".

Gulp install error

So I've been trying to install gulp. I've followed the documentation on its official git page and I've gone though different threats here on SO.
So far i've used the commands: npm install --global gulp-cli and npm install --save-dev gulp
error I keep getting
Check whether your NODE_HOME is proper. On the contrary you can just provide the fully qualified path as the initial gulp command then the task name. Try that too if that works.
Try using:
npm install -g gulp
This has always worked for me in the past.
You might also want to check that you have nodejs installed. To check this, use:
node -v
If you don't, you can download it from here

NPM Experts! Does NPM need to be installed with every JointsWP Gulp Sass project

I'm using JointsWP (an excellent Foundation 6 port to Wordpress).
I'm using the Sass version and it's working great. However, I seem to have to install npm with every project. Is this nessesary?
Is there a way to install npm globally and link to it from my project? Or have the project find it automatically?
I think you are confused about what the command npm install actually does. npm install installs all the npm dependencies for your project into the node_modules directory. It doesn't actually install npm. To run npm install you have to have Node.js installed (npm is included with node).
So to answer your question, yes it is necessary to run npm install for every project.
Relevant Article: Global vs Local installation
The article above shared by Colin Marshall is great and sums up the answer perfectly.
In general, the rule of thumb is:
If you’re installing something that you want to use in your program,
using require('whatever'), then install it locally, at the root of
your project. If you’re installing something that you want to use in
your shell, on the command line or something, install it globally, so
that its binaries end up in your PATH environment variable.
So to answer your question, is it possible? Yes.
Is it recommended? No.
https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/
You can install gulp sass globally with the command:
npm install -g gulp-sass

when i try to use npm to install some package in my win8, it always gives me error like this

This example shows the bcrypt package. But my friends tells me it installs ok on a macbook. Anyone know how to fix this?
node.bcrypt.js depends on node-gyp to compile it's native modules. Unfortunately, node-gyp has further dependencies on Python and Visual Studio C++, which are not installed on Windows by default. You'll need to install those dependencies manually before node-gyp will work. See the node-gyp installation guide for further details.
node.bcrypt.js is well-known for being hard to install on Windows. An alternative, much easier work-around is to use bcrypt.js, which is a drop-in replacement for node.bcrypt.js. It has no dependency on node-gyp, as it has no native modules.

can't install mmmagic with npm install

I want to install module mmmmagic in my projet using npm install mmmgic, I come across the following error
You either don't have MSVC installed or your build environment isn't set up properly. If you do have MSVC installed, you might try using one of the special VS201x Command Prompts and executing your npm install mmmagic from there instead.

Resources