Installing React-native calendars breaks installation - reactjs

I'm a bit puzzled why two different npm installs for a react-native calendar are breaking the solution. I am running react-native through expo, and it runs fine before installing the calendar.
But after installing either
react-native-general-calendars
or
react-native-calendars
I get this error in the console after running
expo start:
> [17:30:29] Starting project at --location--
[17:30:33] Error: React native is not installed. Please run `npm install` in your project directory.
[17:30:33] Couldn't start project. Please fix the errors and restart the project.
[17:30:33] Set EXPO_DEBUG=true in your env to view the stack trace.
I run npm install and get the following error:
> [17:33:34] Starting project at --location--
[17:33:40] --location--\node_modules\react-native\local-cli\server\checkNodeVersion.js:43
[17:33:40] );
[17:33:40] ^
[17:33:40] SyntaxError: Unexpected token )
[17:33:40] at createScript (vm.js:56:10)
[17:33:40] at Object.runInThisContext (vm.js:97:10)
[17:33:40] at Module._compile (module.js:542:28)
[17:33:40] at Object.Module._extensions..js (module.js:579:10)
[17:33:40] at Module.load (module.js:487:32)
[17:33:40] at tryModuleLoad (module.js:446:12)
[17:33:40] at Function.Module._load (module.js:438:3)
[17:33:40] at Module.require (module.js:497:17)
[17:33:40] at require (internal/module.js:20:19)
[17:33:40] at Object.<anonymous> (--location--\node_modules\react-native\local-cli\cli.js:17:1)
[17:33:40] Metro Bundler process exited with code 1
[17:33:40] Set EXPO_DEBUG=true in your env to view the stack trace.
Here is my package.json:
{
"name": "my-new-project",
"main": "node_modules/expo/AppEntry.js",
"private": true,
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#expo/samples": "2.1.1",
"expo": "^29.0.0",
"react": "^16.4.2",
"react-native": "^0.56.0",
"react-native-general-calendars": "^1.7.2",
"react-navigation": "^2.9.3"
},
"devDependencies": {
"jest-expo": "^29.0.0"
}
}
When I uninstall the calendar I still get the error now. Not sure how to get expo to stop throwing the error. Anyone know how to fix this?

Related

after create react app , npm start is not working , each time getting different errors

I tried npm init, update, cache clearing, node js uninstalled and
installed, but nothing helped
After create react app, npm start is not working, each time getting different errors:
D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project A\client\node_modules\cross-spawn\lib\enoent.js:1
$→��m��mo�L�D��;�%g�?w��ŷ↓�▬��ovH0��a�5��*�ؒ��l͛�S�iy☺�r�O7����%L]��%��∟�hk
^
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project A\client\node_modules\cross-spawn\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project B\client copy\node_modules\path-to-regexp\index.js:1
$→��m��mo�L�D��;�%g�?w��ŷ↓�▬��ovH0��a�5��*�ؒ��l͛�S�iy☺�r�O7����%L]��%��∟�hk
^
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\Downloads in Data drive\SourceCodes\Full Stack Web Development\NodeJs\Project B\client copy\node_modules\express\lib\router\layer.js:16:18)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
My Package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.2.0",
"#testing-library/user-event": "^13.5.0",
"ajv-dist": "^8.11.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Go to Command Prompt and locate the directory where you installed Node JS and run this command: node --version.
If it shows the version that you have installed, then run this command: npm --version. If it does not show the version then something is wrong.
Go to Node JS Official Website and download the Long Term Support(LTS) version of Node JS e.g 16.15.0 (according to the posting time of the answer).
Then install it and run the previous commands e.g. node --version & npm --version.
The error should be gone.

failing to run locally create-react-app. npm start gives a syntax error

I'm trying to locally run and debug my client's site but I cannot get it to start locally. I tried updating npm but with no sucess. This site was made with create react app. I am not sure if something wrong is with the code, with my npm or maybe I'm not seeing something very obvious.
I use git clone, then npm i, then npm start and this happens:
compiler.hooks.done.tap('done', async stats => {
^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/filipsikora/Downloads/avrio-shop2-react-1.1/node_modules/react-scripts/scripts/start.js:45:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! shop_2.0#0.1.0 start: `react-app-rewired start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the shop_2.0#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I know that it highlights the word async. I tried to update npm in many ways. Maybe I screwed something up and not updated it correctly.
Here is my package.json just in case
{
"name": "shop_2.0",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.1",
"bootstrap": "^4.5.3",
"firebase": "^6.6.2",
"node-sass": "^4.14.1",
"raven-js": "^3.27.2",
"react": "^16.14.0",
"react-app-rewire-disable-chunks": "0.0.1",
"react-app-rewired": "^2.1.6",
"react-dom": "^16.14.0",
"react-google-recaptcha": "^1.1.0",
"react-horizontal-scrolling-menu": "^0.7.8",
"react-localization": "^1.0.15",
"react-redux": "^6.0.1",
"react-redux-toastr": "^7.6.5",
"react-router-dom": "^5.2.0",
"react-scripts": "2.1.8",
"react-scrollbar": "^0.5.6",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-app-rewired start",
"watch": "node scripts/build-watch.js",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-app-rewired eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"eslint-plugin-react": "^7.21.5"
},
"homepage": "/plugin/shop-app"
}

Yarn encore prod failing

Im trying to deploy a symfony application on my Ubuntu server.
Mind the following details.
It is a simple application but some yarn packages seem to be failing.
What can I do?
Im working with Symfony 5.
My package.json
{
"devDependencies": {
"#symfony/webpack-encore": "^0.30.2",
"bootstrap": "^4.5.2",
"jquery": "^3.5.1",
"node-sass": "^4.14.1",
"popper.js": "^1.16.1",
"webpack-notifier": "^1.6.0"
},
"dependencies": {
"add": "^2.0.6",
"copy-webpack-plugin": "^6.0.3",
"sass-loader": "^8.0.0",
"yarn": "^1.22.4"
},
"name": "fluid-cms",
"version": "1.0.0",
"main": "index.js",
"repository": "---",
"author": "---",
"license": "MIT"
}
The following output comes out.
I have tried many things.
Ubuntu 18.04.
alpha#ovhBrains:/var/www/fluid-cms$ sudo yarn encore prod
yarn run v1.22.4
$ /var/www/fluid-cms/node_modules/.bin/encore prod
Running webpack ...
/var/www/fluid-cms/node_modules/copy-webpack-plugin/node_modules/p-limit/index.js:30
} catch {}
^
SyntaxError: Unexpected token {
at NativeCompileCache._moduleCompile (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-cache.js:242:18)
at Module._compile (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/www/fluid-cms/node_modules/copy-webpack-plugin/dist/index.js:10:38)
at Module._compile (/var/www/fluid-cms/node_modules/v8-compile-cache/v8-compile-
d.
---
Another error:
#symfony/webpack-encore#0.30.2: The engine "node" is incompatible with this module. Expected version ">= 10.13.0". Got "8.10.0"
Once I found out the second error log it was easy to fix.
My nodejs -v was not matching with the requirements.

Problem starting a react-native app in simulator

This is my package.json
{
"name": "Locals",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"#babel/runtime": "^7.3.1",
"react": "16.6.3",
"react-native": "0.58.3",
"react-native-elements": "^1.0.0",
"react-native-vector-icons": "^6.2.0"
},
"devDependencies": {
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "24.0.0",
"jest": "24.0.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
And I get following logs of failure:
Loading dependency graph, done. error: bundling failed: Error: Cannot
find module 'NativeModules'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.get NativeModules [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native/Libraries/react-native/react-native-implementation.js:313:12)
at Object.get [as NativeModules] (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/react-native.js:1:344)
at Object. (/Users/vb05mj/Developer/personal/small-town/Locals/node_modules/react-native-vector-icons/dist/lib/ensure-native-module-available.js:1:238)
at Module._compile (internal/modules/cjs/loader.js:689:30)
Run rm -rf node_modules && npm install to reinstall the dependencies.
Make sure that react-native-vector-icons is properly linked. Usually you should have this line within android/app/build.gradle:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
More info here:
https://github.com/oblador/react-native-vector-icons#android
Kill the npm server (ctrl+c or just run kill -15 [pid]) and restart it using npm start -- --reset-cache
Finally, don't forget to rebuild your app:
./android/gradlew clean && react-native run-android

Unable to import a React Component in my Mocha test

I"m trying to do a simple Mocha test, which works, but once i start trying to add my own components for testing, it is unable to resolve the module.
package.json:
{
"name": "My Project",
"version": "0.1.0",
"scripts": {
"test": "mocha \"./src/**/*.spec.js\""
},
"dependencies": {
"react": "^0.14.7",
"react-dom": "^0.14.7",
"webpack": "^1.12.12"
},
"devDependencies": {
"bower": "^1.4.1",
"expect": "^1.14.0",
"expect-jsx": "^2.3.0",
"jsx-loader": "^0.13.2",
"mocha": "^2.4.5",
"react-addons-test-utils": "^0.14.7"
}
}
src/dashboard/TestComponent.jsx:
var React = require('react');
var TestComponent = React.createClass({
render: function() {
return (
<div />
);
}
});
module.exports = TestComponent;
src/dashboard/test.spec.js:
var React = require("react");
var ReactTestUtils = require('react-addons-test-utils');
var expect = require("expect");
var expectJSX = require("expect-jsx");
expect.extend(expectJSX);
var TestComponent = require('./TestComponent');
describe('Test', function() {
it('should work', function() {
expect(true).toEqual(true)
});
});
If i remove the line var TestComponent = require('./TestComponent.jsx');, my spec passes. But once i try to require my component, it gives me this error:
$ npm test
>My Project#0.1.0 test C:\workspace\root
>mocha "./src/**/*.spec.js"
module.js:338
throw err;
^ Error: Cannot find module './TestComponent'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (C:\workspace\root\src\dashboard\test.spec.js:7:22)
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 Module.require (module.js:365:17)
at require (module.js:384:17)
at C:\workspace\root\node_modules\mocha\lib\mocha.js:219:27
at Array.forEach (native)
at Mocha.loadFiles (C:\workspace\root\node_modules\mocha\lib\mocha.js:216:14)
at Mocha.run (C:\workspace\root\node_modules\mocha\lib\mocha.js:468:10)
at Object.<anonymous> (C:\workspace\root\node_modules\mocha\bin\_mocha:403:18)
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.
Mocha probably can't read your TestComponent because it contains syntax unfamiliar to it (the JSX). You'll need to specify a compiler for mocha as well as babel presets (assuming you're using Babel).
Assuming you already have babel-core and babel-preset-react installed for your project, make these changes in your package.json:
"scripts": {
"test": "mocha --compilers js:babel-register \"./src/**/*.spec.js\""
},
"babel": {
"presets": ["react"]
}
You should add the .jsx extension to your require call, as by default it won't recognize .jsx files as modules.
Rick is also right about the compiler but in this case the error is due to the synthax of require. Then if you fix the require you will see an error of unexpected token, which is the lack of compiler.
You should therefore correct both points.

Resources