How to install qunitjs with git on Karma's? - node.js

I'm trying to work around this error in karma.
QUnit has comitted a fix for the error since v1.14.0, so I want to install qunit from git to work with karma-qunit.
npm rm qunitjs
npm i jquery/qunit
Then I run karma and I get an error, even though ./node_modules/qunitjs is present with a package.json file:
$ ./node_modules/karma/bin/karma start
module.js:340
throw err;
^
Error: Cannot find module 'qunitjs'
at Function.Module._resolveFilename (module.js:338:15)
at Function.require.resolve (module.js:384:19)
at initQUnit (/home/nik/src/dmt/node_modules/karma-qunit/lib/index.js:7:39)
at Array.invoke [as 0] (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at get (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:48:43)
at /home/nik/src/dmt/node_modules/karma/lib/server.js:31:14
at Array.forEach (native)
at start (/home/nik/src/dmt/node_modules/karma/lib/server.js:30:21)
at invoke (/home/nik/src/dmt/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Object.exports.start (/home/nik/src/dmt/node_modules/karma/lib/server.js:306:12)
The error doesn't occur when installing qunit with npm install qunitjs. Anyone know what's going on?
I'm using npm 1.4.16 and node 0.10.25.

Make this folders tree :
./node_modules/
./node_modules/
./qunitjs/
./karma/
Or use npm in karma folder './node_modules/karma/bin/' or './node_modules/karma/'.
cd /home/nik/src/dmt/node_modules/karma/bin/
npm i jquery/qunit

Finally worked this issue out. Turns out I had to install qunitjs globally before it worked.
npm install -g qunitjs
Don't like the solution as it will break module dependancy (for other developers), but seems the only way it worked for me.
I do have Karma installed (via npm) globally too, so maybe that's why.

Related

node:internal/modules/cjs/loader:942 throw err; ^ Error: Cannot find module 'express' Require stack:

I am working on running my express server with the command npm start. I am receiving: ```node:internal/modules/cjs/loader:942
throw err;
^
Error: Cannot find module 'express'
Require stack: ```.
I currently do not have node modules and also receive errors when I type the command npm install. I've deleted node modules outside of the current directory, upgraded the version, & have been googling answers. I would appreciate the help. Thanks so much!
You need to install express as the error is showing that express is missing. The command for that shall be npm install express --save. You have also mentioned that you are receiving error upon running npm install .
Updated
Remove bycrypt-nodejs from your package.json file as it is deprecated. Then run npm install. If you need bycrypt you can run npm install bcrypt or npm install bcryptjs which suits your project better. Afterwards run npm install express --save. Hope this will solve the issue.
This is probably because you are in the wrong folder or your file name is wrong. Try ls to see if all your necessary packages are there. If not go to the right folder and type npm i in the terminal. This should solve the issue of any missing packages. Then use npm run start.

Installing node-sass on ubuntu 18.04 returns error

I'm trying to install node-sass on ubuntu, beacuse I want to use sass-autocompile, but even when I try to compile that sass file in atom (just when I save it)
It returns this error:
`fs.js:904
return binding.readdir(pathModule._makeLong(path), options.encoding)
Error: ENOENT: no such file or directory, scandir
'/usr/lib/node_modules/node-sass/vendor'
at Object.fs.readdirSync (fs.js:904:18)
at Object.getInstalledBinaries (/usr/lib/node_modules/node-
sass/lib/extensions.js:129:13)
at foundBinariesList (/usr/lib/node_modules/node-
sass/lib/errors.js:20:15)
at foundBinaries (/usr/lib/node_modules/node-sass/lib/errors.js:15:5)
at Object.module.exports.missingBinary (/usr/lib/node_modules/node-
sass/lib/errors.js:45:5)
at module.exports (/usr/lib/node_modules/node-sass/lib/binding.js:15:30)
at Object.<anonymous> (/usr/lib/node_modules/node-
sass/lib/index.js:14:35)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)`
I tried to use this command npm rebuild node-sass and it didn't fix the problem, even with --force
And removing nodejs and node-sass and npm and installing again didn't fix the problem and yes I do have ruby installed.
But one thing is really strange: this path node_modules/node-sass/vendor' exists in home folder, basically node_modules exists in home folder even with that vendor folder. Can you help me out ?
Here is the solution which works for me
sudo npm install --unsafe-perm node-sass
Update: Since node-sass is mostly deprecated use instead sass npm module(works perfect whithout any issues).You can find it HERE.
so after reading some of the workarounds on https://github.com/sass/node-sass/issues/1579 here is my suggestion
first remove node_modules directory and re-install dependencies npm install if its still not working then
node node_modules/node-sass/scripts/install.js
npm rebuild node-sass
if it's still not working, change your node-sass version to the latest and re-install it again

ERROR in ./node_modules/css-loader?: ENOENT: no such file or directory node_modules/node-sass/vendor

I was trying to run an angular project in windows 10. It is the same project that I am doing in Ubuntu. When I clone the repository and install all the node packages I encountered this error.
ERROR in
./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader?{"ident":"postcss"}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":false,"precision":8,"includePaths":[]}!./src/scss/style.scss
Module build failed: Error: ENOENT: no such file or directory, scandir
'C:\Users\me\Documents\ad-fingerprinting\web\node_modules\node-sass\vendor'
at Object.fs.readdirSync (fs.js:911:18)
at Object.getInstalledBinaries (C:\Users\me\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\extensions.js:124:13)
at foundBinariesList (C:\Users\me\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\errors.js:20:15)
at foundBinaries (C:\Users\me\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\errors.js:15:5)
at Object.module.exports.missingBinary (C:\Users\me\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\errors.js:45:5)
at module.exports (C:\Users\me\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\binding.js:15:30)
at Object. (C:\Users\me\Documents\ad-fingerprinting\web\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\me\Documents\ad-fingerprinting\web\node_modules\sass-loader\lib\loader.js:3:14)
at Module._compile (module.js:624:30) # ./src/scss/style.scss 4:14-195 # multi ./src/scss/style.scss
node -v 8.5.0
Angular CLI version 1.4.3
Try this
npm install node-sass
Then
npm run start
Run this command:
npm install --save node-sass
This does the same as above. Similarly to the answer above.
I am also facing the same problem, but I resolve.
npm install node-sass
Above command work for me. As per your synario you can use the blow command.
Try 1
npm install node-sass
Try 2
Remove the node_modules folder and run:
npm install
Try 3
npm rebuild node-sass
Try 4
npm install --save node-sass
For your ref you can go through this github link
I tried both
npm rebuild node-sass
and
npm install --save node-sass
Later by seeing EACCESS, i checked the folder permission of /node_modules, which was not 777 permission
Then I gave
chmod -R 777 *
-R for recursively(setting the same permission not in the dir but also inside nested sub dir)
is for all files in current directory
What is file permission
To check for permission you can use
ls -l
If u don't know about it, first see here, then check the url
Every file and directory has permission of 'rwx'(read, write, execute). and if 'x' permission is not there, then you can not execute, if no 'w', you can not write into the file. if something is missing it will show in place of r/w/x with '-'. So, if 'x' permission is not there, it will show like 'rw-'
And there will be 3 categories of user Owner(who created the file/directory), Group(some people who share the same permission and user privilege), Others(general public)
So 1st letter is 'd'(if it is a directory) or '-'(if it is not a directory), followed by rwx for owner, followed by for group, followed by other
drwxrwxrwx
For example, for 'node_modules'directory I want to give permission to the owner all permission and for rest only read, then it will be
drwxr--r--
And about the number assume for 'r/w/x' it is 1 and for '-' it is 0, 777, first 7 is for the owner, followed by the group, followed by other
Let's assume the permission is rwxr-xrw-
Now 'rwx' is like '111' and its equivalent decimal is 12^2+12^1+1*2^0=7
Now 'r-x' is like '101' and its equivalent decimal is 12^2+02^1+1*2^0=5
Now 'rw-' is like '110' and its equivalent decimal is 12^2+12^1+0*2^0=6
So, it will be 756
Laravel Mix 4 switches from node-sass to dart-sass (which may not compile as you would expect, OR you have to deal with the issues one by one)
OR
npm install node-sass
mix.sass('resources/sass/app.sass', 'public/css', {
implementation: require('node-sass')
});
https://laravel-mix.com/docs/4.0/upgrade
Try to run
npm i node-sass#latest
re-install node-sass with version based on your error message
npm install node-sass#v4
you have to update your node.js and angular/cli.If you update these two things then your project has angular.json file instead of angular-cli.json file.Then add css file into angular.json file.If you add css file into angular-cli.json file instead of angular.json file,then errors are occured.
My case:
Missing node-sass in package.json
Solution:
npm i --save node-sass#latest
remove node-modules folder
npm i
check "#angular-devkit/build-angular": "^0.901.0" version in package.json
Step 1:
goto /node_modules/node-sass folder
Step 2:
run yarn install or npm install
If it complains about version incompatibility,
try installing older node-sass versions
And repeat Step 1, Step 2
OR you can add this script in the package.json
"postinstall": "node ./node_modules/node-sass/scripts/install.js"
To be clear node-sass is depracated and must be uninstalled and then a new version of sass must be install.
Do the follow:
1st) try uninstalling it by using this command
npm uninstall node-sass
and then 2nd) try installing sass
npm install --save-dev sass
this worked for me when I was having issues installing sass on a project using create react app
Add the below code in your package.json:
"devDependencies": {
"sass": "^1.49.0"
}
rm -r ./node_modules
npm cache clean --force
npm rebuild node-sass
npm i
npm start

Error: cannot find module npm-shrinkwrap

Setting up bootstrap with grunt.
Getting the following error:
Cannot find module npm-shrinkwrap
Tried npm install shrinkwrap, still getting the same error.
run npm install first on bower_components\bootstrap directory. Then, run grunt dist.

npm install is missing modules

Before I can run gulp in my project I need to run npm install. This works except on my computer, because I get the following error:
Error: Cannot find module 'socket.io'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
...
I can fix this with
$> npm install socket.io
Now when I do the install command again I get
Error: Cannot find module 'di'
...
When I install di and run the install command again I get:
Error: Cannot find module 'log4js'
I think that this might continue for a very long time. Any suggestions what is going on here and how to fix this ?
I've faced the same problem when bootstrapping a MEAN application and add each missing dependencie with npm install packageName --save was not an option so I came across to npm-install-missing whom has saved my life :)
Installation
npm install -g npm-install-missing
Usage
npm-install-missing
Running npm install will install all dependencies that are specified in the package.json. Seems like you have quite a few dependencies that are not defined that way. Use npm install packageName --save and npm will add the package to your package.json.
I am using the same version of npm/node. Sometimes, it is like npm is "lost". What I suggest is :
rm of your node modules (at least the one that is concerned)
npm cache clean
run "npm install" several times, until all dependencies are resolved and no message are displayed
It seems that gulp need 'karma' dependencies (socket.io ,di ,log4js...) so you will have to run :
npm install karma
so just runing this command solved the problem, and all should be good, the same thing happens with grunt as well for some reasons.
This worked for me. By commenting 3 lines in C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js.
Refer [https://flaviocopes.com/cb-apply-not-a-function/]
// fs.stat = statFix(fs.stat) # Line: 61
// fs.fstat = statFix(fs.fstat) # Line: 62
// fs.lstat = statFix(fs.lstat) # Line: 63
Beside other answers, if you are using Angular and cannot make new angular project and hangs, you can get into the folder and open terminal and write:
npm -i
Maybe useful for other things too!!
I think the npm module madge would help you find the missing dependencies. It goes through your actual code and makes a list of all the dependencies found within. You could then do an npm i for each of the modules found.
If the npm-install-missing does not work for you, knowing the name of the Packages that are missing will help you out here. All I had to do was first open my package.json file inside VSCode, then paste or type the names of the missing modules into it (under dependencies) according to the way other package names were written there.
Then I ran npm install after that.
This method is helpful when you are working on a file but somehow you did not get the package.json file or some of the modules are not listed therein.
Remember to stop and restart a running server after you do npm install for your new dependencies to reflect on your work.
Upgrade your npm version
Install nvm which is easier to switch node js versions
For me node 12.18.3 worked
Just do: nvm use 12.18.3 to switch version
run npm install again and node_modules will appear
To resolve missing npm modules run:
sudo npm install -g npm-install-missing

Resources