Error in node packages and node-sass - javascript

I'm receiving this error in javascript console.
I already remove the node_modules and reinstall it and I already run npm rebuild node-sass.
I really don't know what to do anymore.
I'll be very grateful for your help.
app.js:20147 Uncaught Error: Module build failed: ModuleBuildError: Module
build failed: Error: Missing binding /home/vagrant/Quality1/node_modules/node-sass/vendor/linux-x64-57/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 8.x
Found bindings for the following environments:
- Windows 32-bit with Node.js 6.x
- Windows 64-bit with Node.js 6.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass --force` to build the binding for your current environment.
at module.exports (/home/vagrant/Quality1/node_modules/node-sass/lib/binding.js:15:13)
at Object.<anonymous> (/home/vagrant/Quality1/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/vagrant/Quality1/node_modules/sass-loader/index.js:4:12)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
npm rebuild node-sass --force (response)
make: Leaving directory/home/vagrant/Quality1/node_modules/node-sass/build'
gyp info ok
Installed to /home/vagrant/Quality1/node_modules/node-sass/vendor/linux-x64-57/binding.node
node-sass#3.13.1 install /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass
node scripts/install.js
node-sass build Binary found at /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-57/binding.node
node-sass#3.13.1 postinstall /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass
node scripts/build.js
Binary found at /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
node-sass#4.5.3 /home/vagrant/Quality1/node_modules/node-sass
node-sass#3.13.1 /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass
`

change "gulp-sass": "^2.3.2"
to
"gulp-sass": "3.0.0" in package.json
clear the node_modules folder by removing it and then run
npm install
again and it'll not give the error!

You are using node-sass#3.13.1. There was never support for Node 8 for that version.
You can solve this problem in two ways:
Use node-sass#4.5.3 or higher (currently the latest one is 4.7.2). Sometimes node-sass is the dependency of another package, then try to update this package.
Use Node 6. The easiest way to manage different versions of Node between your projects is to use NVM or NVM Windows. I also suggest you use .nvmrc file, that contains desired Node version. Then you will be able to switch between Node version with simply $ nvm use in a project directory.

Related

'npm start' command fails to run my Nodejs API and gives below error

I clone the project from GitLab -> install node_modules by "npm install -g" -> and run "npm start" command in terminal but it give some errors as below.
Error Cannot find module '../services/'
Require stack:
- /opt/projects/api_server_node/node_modules/ravepay/lib/rave.bvn.js
- /opt/projects/api_server_node/node_modules/ravepay/index.js
- /opt/projects/api_server_node/services/flutterwaveService.js
- /opt/projects/api_server_node/controllers/flutterwaveController.js
- /opt/projects/api_server_node/controllers/bookingController.js
- /opt/projects/api_server_node/routes/booking.js
- /opt/projects/api_server_node/index.js
Error: Cannot find module '../services/'
Require stack:
- /opt/projects/api_server_node/node_modules/ravepay/lib/rave.bvn.js
- /opt/projects/api_server_node/node_modules/ravepay/index.js
- /opt/projects/api_server_node/services/flutterwaveService.js
- /opt/projects/api_server_node/controllers/flutterwaveController.js
- /opt/projects/api_server_node/controllers/bookingController.js
- /opt/projects/api_server_node/routes/booking.js
- /opt/projects/api_server_node/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous>
(/opt/projects/api_server_node/node_modules/ravepay/lib/rave.bvn.js:2:22)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/opt/projects/api_server_node/node_modules/ravepay/index.js:17:11)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/opt/projects/api_server_node/services/flutterwaveService.js:16:17)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous>
(/opt/projects/api_server_node/controllers/flutterwaveController.js:28:20)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bookadabra_api#1.0.0 start: `node ./index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bookadabra_api#1.0.0 start script.
npm ERR! This is probably not a problem with npm. The`enter code here`re is likely
additional logging output above.```
screeshot of the error (https://prnt.sc/vpykry)
TL;DR: Downgrade the ravepay module from 1.3.0 to 1.2.4, but do take time to read the WARNING paragraph below first.
The stack trace indicates that your issue is in the ravepay module. Trying to use a plain installation of ravepay resulted in a similar error to what you're seeing for every version of Node.js I tried (15.x, 14.x, 12.x, and 10.x--all the versions currently supported by the Node.js project at the time of this writing).
There's no information about Node.js version support for ravepay, or at least not that I can find as of this writing. However, looking at their GitHub Action at the time of this writing reveals that they use Node.js 12.x. But using 12.x didn't help.
The current version of ravepay is 1.3.0. Downgrading to 1.2.4 fixes the issue.
$ node -v
v15.3.0
$ npm -v
7.0.14
$ npm install ravepay
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
added 61 packages, and audited 61 packages in 3s
2 packages are looking for funding
run `npm fund` for details
2 high severity vulnerabilities
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
$ npm ls ravepay
temp# /Users/trott/temp
└── ravepay#1.3.0
$ node -e "require('ravepay')"
node:internal/modules/cjs/loader:922
throw err;
^
Error: Cannot find module '../services/'
Require stack:
- /Users/trott/temp/node_modules/ravepay/lib/rave.bvn.js
- /Users/trott/temp/node_modules/ravepay/index.js
- /Users/trott/temp/[eval]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
at Function.Module._load (node:internal/modules/cjs/loader:763:27)
at Module.require (node:internal/modules/cjs/loader:991:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/Users/trott/temp/node_modules/ravepay/lib/rave.bvn.js:2:22)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Module.require (node:internal/modules/cjs/loader:991:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/trott/temp/node_modules/ravepay/lib/rave.bvn.js',
'/Users/trott/temp/node_modules/ravepay/index.js',
'/Users/trott/temp/[eval]'
]
}
$ npm install ravepay#1.2.4
changed 1 package, and audited 61 packages in 1s
2 packages are looking for funding
run `npm fund` for details
2 high severity vulnerabilities
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
$ npm ls
temp# /Users/trott/temp
└── ravepay#1.2.4
$ node -e "require('ravepay')"
$
WARNING: Even though that "fixes" the problem, those high severity audit warnings are not a reassuring sign on a credit card payment library. The ravepay module is relatively lightly used (227 weekly downloads at the time of this writing) and was last published a year ago (at the time of this writing). It is probably not much actively maintained and there is not evidence of a user base large enough to frequently surface simple issues like this and make solutions readily available to a user community. If you continue down this path, you may experience more problems like this. Be prepared.
EDIT: Oh yeah, and as #Andrei Ionita notes in their answer, don't install the project dependencies with the -g flag.
Try clearing your globally installed packages and installing the project without the -g flag.

I installed Node.js but I can't use npm on windows

I have installed node.js. Node seems to be working properly, however, npm is not being found, as you can see below.
C:\Users\jpdrc>node -v
v6.5.0
C:\Users\jpdrc>node hello.js
node is installed!
C:\Users\jpdrc>npm -v
module.js:457
throw err;
^
Error: Cannot find module 'strip-ansi'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\jpdrc\AppData\Roaming\npm\node_modules\npm\node_modules\npmlog\node_modules\gauge\node_modules\string-width\index.js:2:17)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
I have tried multiple solutions as the ones presented:
1- Windows -installed node.js but npm not found
2- Installing Node.js (and npm) on Windows 10
I have no idea what to try next
Thanks for the assistance
Here are my variables under path
As suggested below I have used where npm
C:\Users\jpdrc>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
Steps for solving the above issue:
Check that you have added the path of node in environment variable "path"
If it is there then check that npm is there in the directory which you have added in the path.
If npm is there in the required folder then go to CMD and then go to directory where npm is installed and try to run the version command again. If still you are getting the same issue then there could be two possibilities:
a. Installation is incorrect, try installing again
b. There could be proxy issue due to which packages are not getting downloaded
There cannot be any other issue.
You should be able to run the npm -v in the git bash terminal window. If you don't even have the git-bash app, then download and install git on your Windows.

Error at module.js:341 when trying to add android platform to ionic from command line

I am going to use the Ionic framework to work on hybrid app development, so I installed all the necessary dependencies (node.js, cordova, etc.) and followed their Getting started section. Step number 3 simply involves running the following command within the app directory:
> ionic platform add android
However midway during the execution I got the following error:
module.js:341
throw err;
^
Error: Cannot find module 'config-chain'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\james.bonello\AppData\Roaming\npm\node_modules\cordova\node_modules\npm\lib\config\core.js:2:10)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
I ran > npm update first and tried again to see if the update fixes any missing dependencies and such but the problem persisted.
So, as the error clearly states, the module 'config-chain' is missing so I next ran
> npm install config-chain
While that did install the module, the error somehow still persisted (identical to the previous one). I am not sure what to do next and I cannot understand why npm is not recognizing the 'config-chain' module now. Any ideas?
From what I can see, the missing package config-chain is a dependency of the global package cordova.
You should re-install cordova:
npm cache clean
npm uninstall cordova -g
npm install cordova -g
IF the problem persists, you have to manually install the package inside cordova's modules:
C:> cd Users\james.bonello\AppData\Roaming\npm\node_modules\cordova
C:> npm install config-chain
I did npm install and it worked .

How do you fork and develop a globally installed Node.js NPM package?

I'm trying to create a fix for a an NPM package that I rather enjoy, Wintersmith. However, Wintersmith is supposed to be globally installed (executable with wintersmith <command>) and I can't seem to run it from the root of a project where I have it installed locally manually with git clone <my fork url> with something like node ./node_modules/wintersmith/bin/wintersmith without receiving path errors:
module.js:340
throw err;
^
Error: Cannot find module '../lib/cli/'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (F:\web\wintersmith\node_modules\bin\wintersmith:3:1)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
The only way I can figure to properly develop and test this is by manually replacing my globally installed Wintersmith package with my forked version and then executing commands using that version to test whether or not my changes are working.
Is there some workflow step that I'm missing when working with/developing global NPM packages?
You should use npm install git:// instead git clone
Install your fork like this:
npm install git://github.com/YOURNAME/wintersmith.git
You can also install it as global module use -g:
npm install -g git://github.com/YOURNAME/wintersmith.git
NodeJS eats an environment variable NODE_PATH. You can make use of that besides PATH.
This document describes it better:
http://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
I can execute wintersmith like this, without having to install it globally:
$ git clone https://github.com/jnordberg/wintersmith.git
$ cd wintersmith
$ npm install # This installs all dependencies I need for the next step.
$ npm run-script prepublish # Run the prepublish script which compiles sources to ./lib
$ bin/wintersmith
I get the usage message that it gives when there is nothing passed as arguments.
When creating a node package that is meant to be installed globally it is possible and desirable to design it so that it can be run and tested without having to install it. I was surprised that wintersmith would not be designed this way.
Generally speaking, if I had to deal with a node package that cannot be tested without being installed globally, I'd call it "defective". (Maybe there are exceptions but such exceptions are rare and they should be justified in the package's documentation.)
So, generally, if I had to deal with a package that cannot be run and tested without being installed globally, I'd look for a package providing equivalent functionality which can be run without being installed globally, or fix the faulty package.

n module breaks npm

After I switch from one node.js version to another with n module - https://github.com/visionmedia/n/, my npm is broken...
MacBook-Pro-Dmitri:~ dmitri$ npm --version
module.js:340
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at /usr/local/bin/npm:19:11
at Object.<anonymous> (/usr/local/bin/npm:87:3)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
then i'm installing npm again as it was adviced here - https://github.com/visionmedia/n/issues/101
curl https://npmjs.org/install.sh | sh
npm begins to work..
but then i do another switch for node version:
n 0.8.22
and npm now is broken again with the same error.
it's very annoying.. do I need to install npm manually after every version switch?!
Are there different global package repositories for different versions?
Perhaps either that package needs to be re-installed globally sudo npm install -g or the package manage cache cleaned sudo npm cache clean after switching version(s).
Node and npm should get bundled together these days, if you are a frequent version changer like me. You can try installing node with NVM
https://github.com/creationix/nvm
This will help you differentiate packages in different node versions. Just do a npm install after the switch.
PS: The current node version is quite stable right now. You can just use the current version instead of 0.8.22
You could try installing npmlog manually: npm install -g npmlog
I had the same problem and couldn’t find a solution.
It seems that n is less well maintained than nvm so I completely removed node following these steps and re-installed it using nvm.
(And node now includes npm)
I had same problem on windows. I uninstalled node, deleted everything from its install directory and re-installed. After restarting command line, I got npm working again.

Categories

Resources