Error while running jest on node 0.12.0 - reactjs

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

Related

Discord.js bot broke

I read something about this error, but I have discord.js 13.6.0 and node 17.x.x
and I don't know what can couse it.
error:
Error: Cannot find module 'node:events'
Require stack:
- /home/runner/FittingAttachedHacks/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/FittingAttachedHacks/node_modules/discord.js/src/index.js
- /home/runner/FittingAttachedHacks/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous>
(/home/runner/FittingAttachedHacks/node_modules/discord.js/src/client/BaseClient.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
looks like you have installed link, but not the actual node version v17. Try uninstalling wrong package v17.4.0 and install the right version from official site of node.js
The required node version for discord js v13 is node verson of v16 or higher, without it you'll get error like:
1.AbortController is not defined
2.Unexpected token '?'
3.cannot find module 'node:events'
The simple solution is just upgrade to node v16 and the error will be fixed!
Download Node from the website or NVM (Node Version Manager) if you're using Linux.
NVM link: https://github.com/nvm-sh/nvm

run Angularjs application fails

i try to run an angularjs applic, i understood that max version of node that can run it is 6.17.1
so i downloaded it using nvm, and then i run npm install but when i run npm start it failse and it looks like it downloade dependencis of higher versions that use es6 so thats why it fails.
i tried to downgrade specific libraries by deleting them from node modules and installing again specific lower version but when i tried npm show version it looks like its still use the higher version.
the error message is:
Failed to load external module #babel/register
[08:42:09] Requiring external module babel-register
C:\Users\s313240798\source\Workspaces\Nesher\Nesher\Nesher.Client\node_modules\micromatch\index.js:44
let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Module._extensions..js (module.js:586:10)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\s313240798\source\Workspaces\Nesher\Nesher\Nesher.Client\node_modules\babel-register\lib\node.js:152:7)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
i tried to run it also with higher version of node but then the app was on but faild because of th e Incompatibility of versions
This page has some suggestions which may help fix your issue: github.com/gulpjs/gulp/issues/1631
Have you tried this suggestion from the above web page?
npm i -S babel-register

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

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

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.

Resources