When I run karma start I get the following issues
C:\devl\JS\myProject>karma start
06 09 2015 11:30:19.133:WARN [plugin]: Cannot find plugin "karma-chrome-launcher
".
Did you forget to install it ?
npm install karma-chrome-launcher --save-dev
06 09 2015 11:30:19.149:WARN [plugin]: Cannot find plugin "karma-firefox-launche
r".
Did you forget to install it ?
npm install karma-firefox-launcher --save-dev
06 09 2015 11:30:19.159:WARN [plugin]: Cannot find plugin "karma-ie-launcher".
Did you forget to install it ?
npm install karma-ie-launcher --save-dev
when I do npm list I can see the dependencies at the bottom of the tree
├─┬ karma-chrome-launcher#0.2.0
│ ├─┬ fs-access#1.0.0
│ │ └── null-check#1.0.0
│ └─┬ which#1.1.1
│ └─┬ is-absolute#0.1.7
│ └── is-relative#0.1.3
├── karma-firefox-launcher#0.1.6
├─┬ karma-ie-launcher#0.2.0
│ └── lodash#3.10.1
└── karma-jasmine#0.3.6
I have tried nuking my node_dependencies and running npm install again and i'm not sure what else to try
EDIT: I have verified in my node_dependencies directory and the plugin directories are in there.
There are a two seemingly-similar complaints when first getting started with Karma:
[preprocess]: Can not load "webpack", it is not registered!
Perhaps you are missing some plugin?
and
[plugin]: Cannot find plugin "karma-webpack".
Did you forget to install it ?
npm install karma-webpack --save-dev
The following is my best recommendation for fixing these two problems with your configuration…
"Can not load "XYZ", it is not registered!" (sic)
The typical solution to the 'Perhaps you are missing some plugin?' message is to make sure it's included within the plugins array in karma.conf.js.
plugins: [
'karma-chrome-launcher',
'karma-tap',
'karma-sourcemap-loader',
'karma-webpack' // *** This 'registers' the Karma webpack plugin.
],
"Cannot find plugin 'karma-xyz'."
If you've already installed it by running npm install karma-xyz --save-dev, but Karma still prompts (read: taunts) you with the "Did you forget to install it ?" warning, you may have a global installation of the Karma module.
Chances are that when you installed a global copy of the karma-cli using -g, you included karma (or were told to do so by a well-meaning tutorial), but that can cause problems resolving modules in certain versions (i.e., every version I've ever used). Karma's installation documentation recommends that the module should be a local installation using npm install karma --save-dev.
If you have a global Karma installation, try something like:
$ npm uninstall -g karma
$ npm install karma --save-dev
I think that you installed these plugins globally.
I had the same problem and I solved by installing the chrome-karma-launcher using the link flag:
npm install karma-chrome-launcher --save-dev --link
Do this with all browsers' plugins
npm install karma-firefox-launcher --save-dev --link
npm install karma-ie-launcher --save-dev --link
I don't know if this is the best approach, but this solved for me.
My answer might be a very rookie one, but did you add those plugins in the plugins array in the karma config file?
For example:
plugins: [
'karma-jasmine-html-reporter',
'karma-spec-reporter',
'karma-chrome-launcher',
'karma-jasmine',
'karma-coverage',
'karma-phantomjs-launcher'
],
Mine got resolved after I added the plugins to this array.
I had the same problem, but i fixed by this command :
npm install -g karma-cli
Just to add if someone come acrosss!!
I was getting an annoying issue, "Cannot load browser "Chrome": it is not registered! Perhaps you are missing some plugin?" when I run 'grunt test'
I had added the plugin in plugins[] in karma.conf.js, but still I was getting this error . The issue was I didn't add the plugin into karma:options:plugins array in GruntFile.js.After I added the plugin there, the issue vanished!!
Related
I'm having javascript problems related to react. This is the error caught by chrome when page is rendering:
Uncaught TypeError: Super expression must either be null or a function, not undefined
at _inherits (application.js:16301)
at application.js:16310
at Object.232.prop-types (application.js:16549)
at s (application.js:1)
at application.js:1
at Object.233../Collapse (application.js:16574)
at s (application.js:1)
at application.js:1
at Object.1.react (application.js:78)
at s (application.js:1)
When I've install my react using npm it complains about peer dependencies of react and react-height:
├─┬ UNMET PEER DEPENDENCY react#0.14.9
│ ├─┬ envify#3.4.1
│ │ └─┬ jstransform#11.0.3
│ │ ├── base62#1.1.2
│ │ ├─┬ commoner#0.10.8
│ │ │ ├─┬ commander#2.9.0
...
And:
├─┬ UNMET PEER DEPENDENCY react-height#2.2.1
│ └─┬ create-react-class#15.5.2
│ └─┬ fbjs#0.8.12
│ └── core-js#1.2.7
After that I changed my package.json file to:
"react": "0.14.9",
"react-bootstrap": "^0.28.1",
"react-collapse": "^2.2.1",
"react-dom": "^0.14.3",
"react-height": "2.2.1",
...
After these changes I removed completely node_modules folder with rm -rf did an npm cache clean and reinstall again.
The VERY SAME problem continues to occur. I notice 2 warnings:
npm WARN react-collapse#2.4.0 requires a peer of react#>=15.3 but none was installed.
npm WARN react-collapse#2.4.0 requires a peer of react-height#^3 but none was installed.
Is there a problem to update the packages or a problem related to react itself?
Your react version doesn't meet react-collapse requirements. It doesn't really mean that both packages can't work together, just try it and if everything works as intended.
But if you need to fix that you have two ways of doing that:
First way
Delete "react": "0.14.9", line, and run npm i --save react. NPM will install latest react package. Error should be fixed.
Second way
If you really need to use 0.14.9 version you should find react-collapse version which is compatible with your reactjs version.
To do so type in your console npm show react-collapse versions - an array of records will show up.
Now we have to pick one earlier version and check the peerDependencies
of our selected package.
We use npm view react-collapse#3.0.0 command, the result will be
Because we selected #3.0.0 version which is ok in our case, we need to install it. Following command will do the work npm install --save react-collapse#3.0.0.
UPDATE
If above solution does not work. Please install missing peerDependencies manually via npm i --save <package-name>.
Explaination:
Check your npm version doing npm -v. If your version is > 3 then it means peer dependencies must be installed manually. I guess that is the case, version 3.0.0 was released in mid 2015.
The automatic install of peer dependencies was explicitly removed with
npm 3, as it cause more problems than it tried to solve.
Please read official npm changelog, you are looking for section "breaking changes".
There is CLI tool which installs an NPM package and its peer dependencies automatically. You might be interested in.
Make sure you have a package.lock.json file in your directory. React uses yarn command, instead of trying npm install try doing yarn add <package name>
I had the same peer dependency error during netlify build and deploy with my react-elastic-carousel and the only thing that solved it was.
yarn add react-elastic-carousel
Hope it helps!
I ran into an issue today mid-class. I was showing my class how to install and use gulp.js, so I had to show the process on a projector.
I've installed node.js and gulp.js globally with npm install -g gulp and it all works fine.
But when I try to install gulp locally in the project folder I am working on, it looks like gulp is installed, but the node_modules folder is never created.
I tried refreshing, I tried running the command prompt as admin, I've checked for hidden folders, nothing works. --- I even restarted and tried again, cause Windows.
I am working on windows 10.
Transcript of command line output:
C:\Xampp\htdocs\test> node -v
v4.2.4
C:\Xampp\htdocs\test> npm -v
2.14.12
C:\Xampp\htdocs\test> gulp -v
[16:40:28] CLI version 3.9.1
[16:40:28] Local version 3.9.1
C:\Xampp\htdocs\test> npm install --save-dev gulp
npm WARN deprecated minimatch#2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch#0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs#1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs#^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
gulp#3.9.1 ..\..\..\node_modules\gulp
├── interpret#1.0.1
├── pretty-hrtime#1.0.3
├── deprecated#0.0.1
├── archy#1.0.0
├── minimist#1.2.0
├── tildify#1.2.0 (os-homedir#1.0.2)
├── semver#4.3.6
├── v8flags#2.0.11 (user-home#1.1.1)
├── chalk#1.1.3 (escape-string-regexp#1.0.5, supports-color#2.0.0, ansi-styles#2.2.1, strip-ansi#3.0.1, has-ansi#2.0.0)
├── orchestrator#0.3.8 (stream-consume#0.1.0, sequencify#0.0.7, end-of-stream#0.1.5)
├── gulp-util#3.0.8 (array-differ#1.0.0, lodash._reescape#3.0.0, beeper#1.1.1, lodash._reevaluate#3.0.0, array-uniq#1.0.3, object-assign#3.0.0, lodash._reinterpolate#3.0.0, dateformat#2.0.0, replace-ext#0.0.1, has-gulplog#0.1.0, fancy-log#1.3.0, vinyl#0.5.3, gulplog#1.0.0, lodash.template#3.6.2, through2#2.0.3, multipipe#0.1.2)
├── vinyl-fs#0.3.14 (strip-bom#1.0.0, vinyl#0.4.6, defaults#1.0.3, graceful-fs#3.0.11, through2#0.6.5, mkdirp#0.5.1, glob-stream#3.1.18, glob-watcher#0.0.6)
└── liftoff#2.3.0 (lodash.isstring#4.0.1, lodash.isplainobject#4.0.6, lodash.mapvalues#4.6.0, extend#3.0.0, rechoir#0.6.2, flagged-respawn#0.3.2, resolve#1.2.0, fined#1.0.2, findup-sync#0.4.3)
Note: npm is in my PATH.
You need either package.json or folder named node_modules in the current directory. If you are not going to have one, npm will look for either one in the parent directories. Check answer to NPM Installs Package Outside Current Directory for more details.
Also it is advised to start with npm init which will create package.json for you.
I am trying to make use of React-Native-Web, but the master branch version of ListView gives the error: TypeError: undefined is not a constructor (evaluating 'new _reactNative.ListView.DataSource')
One of the pull requests on the project adds the ListView functionality I need.
How do I add this PR to my own project?
What I have tried:
created my own fork and manually added the files then tried to use npm to load it directly as per this SO question, it did not work, key core components were missing. The way one normally installs React-Native-Web is npm install --save react#0.14 react-dom#0.14 react-native-web and I tried npm install https:https://github.com/mcampsall/react-native-web
adding the files directly to my /dist folder. This did not work because I needed the babel translated versions of the files. I tried to use the babel REPL to translate them, but it is missing some plugins and gets hung up on certain parts of the code.
Thanks in advance.
EDIT: I just tried npm install --save react#0.14 react-dom#0.14 https://github.com/mcampsall/react-native-web as per Molda's suggestion and got:
├── babel#6.5.2 extraneous
├── babel-plugin-transform-decorators#6.8.0
├── babel-plugin-transform-decorators-legacy#1.3.4
├── babel-preset-react#6.5.0
├── UNMET PEER DEPENDENCY react#0.14.8
├── UNMET PEER DEPENDENCY react-dom#0.14.8
└─┬ react-native-web#0.0.25 (git+https://github.com/mcampsall/react-native-web.git#b448fb94cb29d08057eb72e4c13d09ad808f719a)
├─┬ fbjs#0.8.3
│ └── object-assign#4.1.0
└── react-textarea-autosize#4.0.3
npm WARN react-native-web#0.0.25 requires a peer of react#^15.1.0 but none was installed.
npm WARN react-native-web#0.0.25 requires a peer of react-dom#^15.1.0 but none was installed.
EDIT 2: tried npm install --save react#15.1.0 react-dom#15.1.0 https://github.com/mcampsall/react-native-web and when i do this i get an error npm WARN react-native#0.23.1 requires a peer of react#^0.14.5 but none was installed. which is a different version of react-native-web(0.23.1) than the original error (which was 0.25)...?
I then tried installing react#14.5 and it showed the original error again npm WARN react-native-web#0.0.25 requires a peer of react#^15.1.0 but none was installed.
I just tried this
npm install --save react#15.1.0 react-dom#15.1.0 git+https://git#github.com/mcampsall/react-native-web
and it installs without any error.
Make sure you delete all the packages before you install again or try to install into new empty folder
I am trying to install node in my mac..
i am getting the following error...
i downloaded the node from node site and ran that package...
can you guys tell me why i am facing that errror..when i do npm install
MacBook-Pro:~ Raj$ npm install
npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open '/Users/Raj/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.
npm ERR! System Darwin 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/Raj
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /Users/Raj/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Raj/npm-debug.log
npm ERR! not ok code 0
Running just "npm install" will look for dependencies listed in your package.json. The error you're getting says that you don't have a package.json file set up (or you're in the wrong directory).
If you're trying to install a specific package, you should use 'npm install {package name}'. See here for more info about the command.
Otherwise, you'll need to create a package.json file for your dependencies or go to the right directory and then run 'npm install'.
I had this problem when trying to run 'npm install' in a Terminal window which had been opened before installing Node.js.
Opening a new Terminal window (i.e. bash session) worked. (Presumably this provided the correct environment variables for npm to run correctly.)
In my case it was due to a bad URL (http:// instead of git://, no .git at the end) for one of the dependencies.
You're likely not in the node directory. Try switching to the directory that you unpacked node to and try running the command there.
In case it helps anyone else - my issue was a rookie error, I had a space in the name line of my package.json and it caused the dependencies to be unreadable.
I came across this, and my issue was using an older version of node (3.X), when a newer version was required.
The error message actually suggested this as well:
...
Make sure you have the latest version of node.js and npm installed
...
So the solution may be as simple as upgrading node/npm. You can easily do this using nvm, the "Node Version Manager"
After you've installed nvm, you can install and use the latest version of node by simply running this command:
nvm install node
For example:
$ nvm install node
Downloading https://nodejs.org/dist/v8.2.1/node-v8.2.1-darwin-x64.tar.xz...
######################################################################## 100.0%
Now using node v8.2.1 (npm v5.3.0)
$ node --version
v8.2.1
In mac you might have downloaded and installed Node js in
/Users/yourusername/Downloads/nodejs-todo-master , so go here and run npm install command, no need of sudo as well., you should get output like this...
underscore#1.4.4 node_modules/underscore
ejs#0.8.8 node_modules/ejs
redis#0.8.6 node_modules/redis
jasmine-node#1.0.28 node_modules/jasmine-node
├── walkdir#0.0.7
├── coffee-script#1.8.0 (mkdirp#0.3.5)
├── requirejs#2.1.15
└── jasmine-reporters#1.0.1 (mkdirp#0.3.5)
express#3.0.6 node_modules/express
├── methods#0.0.1
├── fresh#0.1.0
├── range-parser#0.0.4
├── cookie-signature#0.0.1
├── buffer-crc32#0.1.1
├── cookie#0.0.5
├── commander#0.6.1
├── mkdirp#0.3.3
├── debug#2.1.0 (ms#0.6.2)
├── send#0.1.0 (mime#1.2.6)
└── connect#2.7.2 (pause#0.0.1, bytes#0.1.0, formidable#1.0.11, qs#0.5.1)
First download json package file from https://github.com/npm/read-package-json
and then run npm install from terminal.
This is all because you are not in the desired directory. You need to first get into the desired directory. Mine was angular-phonecat directory. So I typed in cd angular-phonecat and then npm install.
If someone is in my situation facing this error and have tried all the above solutions, like:
you are in the right directory
you have a package.json file,
the JSON is valid,
you have tried to run %temp%
you have tried " npm install -d --save"
etc.
Mine worked by doing "npm install --force"
Note: This was also recommended in the error itself, which I didn't pay attention to earlier.
Even " Yarn install" worked.
npm install -d --save worked for me. -d flag command force npm to install your dependencies and --save will save the all updated dependencies in your package.json
For me I'm on windows 10 X64...
My code npm install on cmd failed
So instead of npm i used Yarn
Just type yarn install instead of npm install
This fixed my problem.Tried for 2 days finally found the best
solution
To install yarn , on cmd enter the following code
npm install --global yarn
To check if it has installed correctly enter the following code
yarn --version
Hey if you found error and it stuck while installing then try this
Open run and type %Temp% and delete all file
Then type prefetch on run app an delete all files then try it
These Will do the Job
npm install -g yarn
yarn install
or
npm install --force
Hey if you found error and stcuk while installing packages
,getting only three files like json file ,lock file and module file using yarn then try this using yarn.
Open run and type %Temp% and delete all file
Then type prefetch on run app an delete all files
Then type on CMD npx create -react-app it will give you all packages
In a node.js script that I'm working on, I want to print all node.js modules (installed using npm) to the command line. How can I do this?
console.log(__filename);
//now I want to print all installed modules to the command line. How can I do this?
If you are only interested in the packages installed globally without the full TREE then:
npm -g ls --depth=0
or locally (omit -g) :
npm ls --depth=0
Use npm ls (there is even json output)
From the script:
test.js:
function npmls(cb) {
require('child_process').exec('npm ls --json', function(err, stdout, stderr) {
if (err) return cb(err)
cb(null, JSON.parse(stdout));
});
}
npmls(console.log);
run:
> node test.js
null { name: 'x11', version: '0.0.11' }
list of all globally installed third party modules, write in console:
npm -g ls
in any os
npm -g list
and thats it
Generally, there are two ways to list out installed packages - through the Command Line Interface (CLI) or in your application using the API.
Both commands will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure.
CLI
npm list
Use the -g (global) flag to list out all globally-installed packages. Use the --depth=0 flag to list out only the top packages and not their dependencies.
API
In your case, you want to run this within your script, so you'd need to use the API. From the docs:
npm.commands.ls(args, [silent,] callback)
In addition to printing to stdout, the data will also be passed into the callback.
Why not grab them from dependencies in package.json?
Of course, this will only give you the ones you actually saved, but you should be doing that anyway.
console.log(Object.keys(require('./package.json').dependencies));
for package in `sudo npm -g ls --depth=0 --parseable`; do
printf "${package##*/}\n";
done
As the end of 2021, there are few obvious way to do it, and a part as the only one give on the answer above this is a complete list.
The Node.js Documentation is actually pretty well explained regarding the matter, this is a collective list of the main commands.
All Commands will run the list of installed modules Locally. In order to run global level just add a -g flag at the end of the statement.
See the version of all installed npm packages, including their dependencies.
❯ npm list
>>> /Users/joe/dev/node/cowsay
└─┬ cowsay#1.3.1
├── get-stdin#5.0.1
├─┬ optimist#0.6.1
│ ├── minimist#0.0.10
│ └── wordwrap#0.0.3
├─┬ string-width#2.1.1
│ ├── is-fullwidth-code-point#2.0.0
│ └─┬ strip-ansi#4.0.0
│ └── ansi-regex#3.0.0
└── strip-eof#1.0.0
Get only your top-level packages
npm list --depth=0
Get the version of a specific package by specifying its name.
npm list <package-name>
See what's the latest available version of the package on the npm repository
npm view <package-name> version
Install an old version of an npm package using the # syntax
npm install #
npm install cowsay#1.2.0
Global package
npm install -g webpack#4.16.4
Listing all the previous versions of a package
npm view cowsay versions
[ '1.0.0',
'1.0.1',
'1.0.2',
'1.0.3',
'1.1.0',
'1.1.1',
'1.1.2',
'1.1.3',
....
]
Update all the Node.js dependencies
Install new minor or patch release
npm update
Install new minor or patch release but not update package.json
npm update --no-save
To discover new releases of the packages, this gives you the list of a few outdated packages in one repository that wasn't updated for quite a while
npm outdated
Some of those updates are major releases. Running npm update won't update the version of those. Major releases are never updated in this way because they (by definition) introduce breaking changes, and npm wants to save you trouble.
To update all packages to a new major version, install the npm-check-updates package globally:
npm install -g npm-check-updates
ncu -u
This will upgrade all the version hints in the package.json file, to dependencies and devDependencies, so npm can install the new major version
Dev Dependency
Install in development dependencies.
npm install <package-name> -D
npm install <package-name> --save-dev # same as above
Avoid installing those development dependencies in Production with
npm install --production
Uninstalling npm packages
npm uninstall <package-name>
npm uninstall -g <package-name> # globally uninstall
Uninstall a package and ** remove the reference in the package.json**
npm uninstall <package-name> -S
npm uninstall <package-name> --save # same as above
Some commands with global flag examples.
npm list -g
npm list --depth=0 -g
npm list <package-name> -g
npm view <package-name> version -g
Additional Commands
Answer by #prosti
Documentation
Find the installed version of an npm package
Install an older version of an npm package
Update all the Node.js dependencies to their latest version
Semantic Versioning using npm
Uninstalling npm packages
npm global or local packages
npm dependencies and devDependencies
The npx Node.js Package RunnerTABLE OF CONTENTS