"No provider error" on Karma serve running angularjs phonecat tutorial - angularjs

I have found and tried many solutions offered here and elsewhere: re downgrading karma version upgrading node and npm - changing order of load in the config file....
but so far nothing works. Is the problem that I am running the angular tutorial via Apache?
Starting Karma Server (http://karma-runner.github.io)
/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9
throw error('No provider for "' + name + '"!');
^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
at error (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:22:68)
at Object.parent.get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13)
at get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19)
at /usr/local/lib/node_modules/karma/lib/server.js:28:14
at Array.forEach (native)
at start (/usr/local/lib/node_modules/karma/lib/server.js:27:21)
at invoke (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Object.exports.start (/usr/local/lib/node_modules/karma/lib/server.js:204:12)
at Object.<anonymous> (/usr/local/lib/node_modules/karma/bin/karma
/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9
throw error('No provider for "' + name + '"!');
^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
at error (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:22:68)
at Object.parent.get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:9:13)
at get (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:54:19)
at /usr/local/lib/node_modules/karma/lib/server.js:28:14
at Array.forEach (native)
at start (/usr/local/lib/node_modules/karma/lib/server.js:27:21)
at invoke (/usr/local/lib/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Object.exports.start (/usr/local/lib/node_modules/karma/lib/server.js:204:12)
at Object.<anonymous> (/usr/local/lib/node_modules/karma/bin/karma:19:39)
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)
at startup (node.js:119:16)
at node.js:901:3

You have to install jasmine:
npm install -g karma-jasmine

The selected answer didn´t work for me, this is what it work for me:
https://github.com/karma-runner/karma/issues/880
Karma needs to load the plugins (such as karma-jasmine). By default
(if you don't specify config.plugins), Karma loads all the karma-*
modules that are siblings to Karma.
It sounds like you have Karma installed globally (npm install -g
karma) and jasmine plugin locally (npm install karma-jasmine). If
that's the case, install Karma locally.
The recomended way is to install Karma and all the plugins locally,
per project.

as per the documentation following plugins are required.
// these plugins will be require() by Karma
'karma-jasmine',
'karma-chrome-launcher'
So add these two to your plugin section.

I don't know what platform/os/version you're on, but for me, on mac os x 10.9 ("Mavericks"), I was running into the exact same issue with trying to run karma on an e2e test with the simple angular docs tutorial in their step 3. I solved it in a pretty silly/dumb way =>
Closed the terminal/shell window in which I had all these problems
Re-opened a new terminal/shell window
Ran everything with sudo in front
It all installed/worked, including... npm install -g.
so there you go.

Related

Failed to load configuration of my react native project

./gradlew clean command in the android directory has issues too. I've tried downgrading the npm version but no help. Any ideas?
Below is the log I get when I run npx react-native run-android:
error Failed to load configuration of your project.
Error: Cannot find module '...\node_modules\json-parse-better-errors\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:320:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (D:\projects\Beauty\node_modules\parse-json\index.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
Environment:
OS: Windows 10
react native: 0.65.1
Node: 14.17.4
npm: 7.23.0
use this command for installing the node module first
npm install --force
after that use
npx react-native run-android
for running the project
Happened to me earlier today because of mixing between npm and yarn package managers, a simple npm install solved this. No need to include --force flag.
I got this in an nx monorepo only for a specific app (but not others). None of the above methods worked for me. Finally figured this -
TLDR;
This is not the actual error (you probably guessed this). This error message comes from node_modules/#react-native-community/cli/build/index.js OR node_modules/react-native/node_modules/#react-native-community/cli/build/index.js.
To be sure, you can run this in node_modules directory: find . -name '*.js' -print0 | xargs -0 grep "Failed to load configuration of your project"
2. Edit these files to print the underlying error.
} catch (error) {
/**
* When there is no `package.json` found, the CLI will enter `detached` mode and a subset
* of commands will be available. That's why we don't throw on such kind of error.
*/
if (error.message.includes("We couldn't find a package.json")) {
_cliTools().logger.debug(error.message);
_cliTools().logger.debug('Failed to load configuration of your project. Only a subset of commands will be available.');
} else {
//---> ***** Print the underlying error!
console.log('=============>', error);
throw new (_cliTools().CLIError)('Failed to load configuration of your project.', error);
}
}
For me, this printed: =============> [CLIError: Node module directory for package react-native-animated-pagination-dots was not found]
All I had to do fix it was yarn add react-native-animated-pagination-dots. If only CLI had printed this underlying error, it would have saved me several hours! :-/
Longer explanation
When upgrading my monorepo, I somehow landed in a situation where one of the packages got removed from my packages.json, presumably because yarn couldn't resolve it (in my case this package was react-native-animated-pagination-dots). Then the app which had this dependency started getting this error, the other app didn't.

create-react-app not working due to postcss

I am currently learning react, and started a new app with create-react-app.
I navigated into the new app, then ran npm start.
I got this error message:
Error: Cannot find module '~/Desktop/forms-test/node_modules/postcss-safe-parser/node_modules/postcss/lib/tokenize'
at createEsmNotFoundErr (internal/modules/cjs/loader.js:907:15)
at finalizeEsmResolution (internal/modules/cjs/loader.js:900:15)
at resolveExports (internal/modules/cjs/loader.js:432:14)
at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (~/Desktop/forms-test/node_modules/postcss-safe-parser/lib/safe-parser.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
Any help would be very useful.
I am running Mac OS Catalina, using npm, and running zsh. I am using node version 14.13.1
For others digging around, I followed the instructions on this answer.
rm yarn.lock
yarn install
And that reinstalled everything and properly exported the lib/tokenize path inside of node_modules/postcss-safe-parser/node_modules/postcss/package.json.

ReactNative: Trying to debbug cannot find module

I'm trying to debug my app. In the past everything worked perfectly. Then I formatted the computer, downloaded the project I had saved from git.
At this point, every time I try to run npm start in the terminal or to use the react native tool of visual studio code to debug the app or in any case to update the app connected to my device I get this error:
Error: Cannot find module '/Users/..../node_modules/#react-native-community/cli/build/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:338:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:719:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1072:27)
at Function.Module._load (internal/modules/cjs/loader.js:928:27)
at Module.require (internal/modules/cjs/loader.js:1145:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (/Users/.../node_modules/react-native/cli.js:12:11)
at Module._compile (internal/modules/cjs/loader.js:1256:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32) {
code: 'MODULE_NOT_FOUND',
path: '/Users/..../node_modules/#react-native-community/cli/package.json',
requestPath: '#react-native-community/cli'
I don't understand how can I do.
I remember that before when I made a change to the code I just needed to run npm start to reload my project and see the changes in my device. Now I absolutely can't get the code and device to interact.
How can I do?
You try reinstall React LI:
npm install –g react-native-cli
and install dependences:
npm install

Error while running jest on node 0.12.0

I'm trying to run Jest test in my project and I have node v0.12.0 , so running the Jest test gives me the error below:
/Users/ajaybeniwal203/ODeskWork/ui-components/node_modules/jest-cli/node_modules/harmonize/harmonize.js:31
node.stdout.pipe(process.stdout);
TypeError: Cannot read property 'pipe' of undefined
at module.exports (/Users/ajaybeniwal203/ODeskWork/ui-components/node_modules/jest-cli/node_modules/harmonize/harmonize.js:31:20)
at Object.<anonymous> (/Users/ajaybeniwal203/ODeskWork/ui-components/node_modules/jest-cli/bin/jest.js:39:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3 npm ERR! Test failed.
See above for more details.
How do I resolve this?
It is known issue:
It's known and has to do with JSDOM + contextify mostly.
Try using node 0.10 instead, nvm or similar alternatives available for windows should help.
Cool Question. This is due to Jest does NOT support Node v0.12
Unfortunately, there is NO way to resolve this so far (jest v0.4.x); however, here is workaround: Use v0.10
Try to use nvm to switch node version for your development env:
Switch to previous version
nvm use 0.10
Rebuild dependencies
npm rebuild
Run tests on previous version
npm test
FYI, if you use Node, the next version of Jest (v0.5) will NOT support; if you use io.js, it's all good to continue.
I have using Jest since v0.1 and sorry to say that I have 0 confidence on it anymore. I will switch to Mocha then.
HTH

Integrating Karma and webstorm

I would like to integrate Karma and webstorm for windows, I have followed the steps from this web:
http://mobicon.tistory.com/273 (translate it to english) but does not work.
I have created one Karma Server and a Karma run:
In Path to Node Js File textfield, I have pointed to a karma file from the node-modules:
C:\Users\xxx\AppData\Roaming\npm-cache\karma\0.8.4\package\bin\karma
In the application parameters for the server start and for the Karma Run run
I get the following errors:
module.js:340
throw err;
^
Error: Cannot find module 'optimist'
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 Object.<anonymous> (C:\Users\Javito\AppData\Roaming\npm-cache\karma\0.8.4\package\lib\cli.js:2:16)
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)
at Module.require (module.js:362:17)
Process finished with exit code 1
The problem was the Karma execution file (Path to node App JS file) I was pointing to, here is my configuration for both server and run:
Karma Server:
Karma Run:
Trying to run sails app(app.js nodejs) in Webstorm gave me the optimist error in Ubuntu 14(32 bits). I fixed it by running:
sudo npm install optimist
Cheers!

Resources