redux-trunk library not installing in react native - reactjs

When I install redux-thunk it shows an error and you can see attached image for more info -
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\siddharth.vyas\Desktop\react-native_Proj\AwesomeProject\node_modules.staging\redux-thunk-069b38d0' -> 'C:\Users\siddharth.vyas\Desktop\react-native_Proj\AwesomeProject\node_modules\redux-thunk'
And I have also try to install "redux-thunk" with the administrator but shows the same error.
Pakage.json -
"dependencies": {
"axios": "^0.19.0",
"react": "16.8.3",
"react-native": "0.59.9",
"react-native-loading-spinner-overlay": "^1.0.1",
"react-redux": "^7.1.0",
"redux": "^4.0.1",
"redux-axios-middleware": "^4.0.0"
},
"devDependencies": {
"#babel/core": "7.4.5",
"#babel/runtime": "7.4.5",
"babel-jest": "24.8.0",
"jest": "24.8.0",
"metro-react-native-babel-preset": "0.54.1",
"react-test-renderer": "16.8.3"
},

try removing node_modules and do npm install. If it doesn't work, delete node_modules, add "redux-thunk": "^2.3.0" to your dependencies, then run npm install -i

I have faced similar issues in windows. this looks more of a permission issue.
Try running the cmd window in run as administrator mode. this should mostly give permission to npm to execute the script.
if that does not work, then the option would be to delete the folder redux-thunk from node_modules directory and try reinstalling the redux-thunk module again

Related

How to solve chromium and certificate error while doing npm i

I have cloned the project from github and trying to run the react project in VS code.
I ran npm i and also tried npm i --force.
This is the log
npm WARN deprecated core-js#2.6.12: core-js#<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path C:\Users\55393\Desktop\Rapidx_Documentation\website\node_modules\puppeteer
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
npm ERR! ERROR: Failed to download Chromium r722234! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
npm ERR! Error: self signed certificate in certificate chain
npm ERR! at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)
npm ERR! at TLSSocket.emit (events.js:315:20)
How to solve this?
I have attached package.json below
{
"scripts": {
"examples": "docusaurus-examples",
"start": "docusaurus start",
"build": "docusaurus build",
"serve": "docusaurus serve",
"publish-gh-pages": "docusaurus-publish",
"write-translations": "docusaurus-write-translations",
"version": "docusaurus-version",
"rename-version": "docusaurus-rename-version",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"docusaurus": "docusaurus"
},
"engines": {
"node": "v17.6.0"
},
"dependencies": {
"#azure/msal-browser": "^2.28.0",
"#azure/msal-react": "^1.4.4",
"#docusaurus/core": "^2.0.0-rc.1",
"#docusaurus/plugin-client-redirects": "^2.1.0",
"#docusaurus/plugin-content-docs": "^2.0.0-rc.1",
"#docusaurus/preset-classic": "^2.0.0-rc.1",
"#fortawesome/react-fontawesome": "^0.1.18",
"#mui/material": "^5.10.3",
"axios": "^0.27.2",
"bootstrap": "^5.1.3",
"chart.js": "^3.8.0",
"clsx": "^1.1.1",
"docker": "^1.0.0",
"docusaurus": "^1.14.7",
"docusaurus-lunr-search": "^2.1.15",
"docusaurus-pdf": "^1.2.0",
"docusaurus2-dotenv": "^1.4.0",
"env-cmd": "^10.1.0",
"jquery": "^3.6.0",
"moment": "^2.29.4",
"react": "^17.0.2",
"react-bootstrap": "^2.4.0",
"react-chartjs-2": "^4.3.1",
"react-dom": "^17.0.2",
"react-icons": "^4.4.0",
"react-markdown-editor-lite": "^1.3.2",
"react-paginate": "^8.1.3",
"react-player": "^2.10.1",
"react-scripts": "^5.0.1"
},
"devDependencies": {
"dotenv": "^16.0.2"
}
}

React NPM inefficient regular expression complexity in nth-check

I googled lot about this issue.
But could not find this issue belongs to which library?
How to fix it?
any help will be appreciated
"resolutions" :{
"nth-check":"2.0.1"
}
Add it in Package.json then run npm install
This is a known issue, and it should not affect your actual app as it's coming from react-scripts package.
Open package.json. You will find this:
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3"
}
Take react-scripts and move it to devDependencies (if you don't have it, create it):
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"react-scripts": "4.0.3"
},
Then, ensure you run npm audit --production rather than npm audit.
You can read more from official sources:
https://github.com/facebook/create-react-app/issues/11174#issuecomment-979449264

Cannot find module '#babel/preset-react'

I was trying to deploy my reactjs rails app on heroku.
Everything seems okay until I get this error:
Module build failed (from ./node_modules/babel-loader/lib/index.js):
remote: Error: Cannot find module '#babel/preset-react'
The app works fine in my localhost. I tried deleting my node_modules folder then running npm install but the error persisted(only when deploying at heroku).
My package.json:
{
"name": "App",
"private": true,
"dependencies": {
"#rails/webpacker": "5.4.0",
"#types/react": "^17.0.18",
"#types/react-dom": "^17.0.9",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react_ujs": "^2.6.1",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"
},
"devDependencies": {
"#babel/plugin-syntax-jsx": "^7.14.5",
"#babel/plugin-transform-react-jsx": "^7.14.9",
"#babel/preset-env": "^7.15.0",
"#babel/preset-react": "^7.14.5",
"webpack-dev-server": "^3.11.2"
}
}
I managed to deploy it. I based my answer here: Why is devDependencies' pruning skipped even if NPM_CONFIG_PRODUCTION is true?
What I did was set:
NPM_CONFIG_PRODUCTION= false
YARN_PRODUCTION = false
YARN_CONFIG_PRODUCTION = false
I tested changing ENV values and this what worked for me.
This can set at heroku settings under config vars
Heroku defaults to NODE_END=production. How does this affect your build?
You have #babel/preset-react in devDependencies. When you do npm i (or yarn) to install packages with NODE_ENV=production, npm (or yarn) only installs dependencies (it wont install devDependencies).
To get around this, you can -
either override NODE_ENV. ($ NODE_ENV=development npm i)
Run npm i --only=dev before you build
To be on the safe side, revert the value on NODE_ENV to production when you run in production environment (Heroku in your case).

How to make React and Redux template as small as possible after npm install?

The template being considered is https://github.com/StephenGrider/ReduxSimpleStarter
After git clone, the folder is merely 160kb.
But after npm install, the folder is 620MB.
Is there a way to make it as small as possible? It was suspected that the react native stuff (including the binaries?) is really huge, so can something be done such as npm install --minus react-native if react native is not needed at all?
P.S. a few days have passed, and today Apr 2, 2017, the same repo, the same as before, after npm install, is only 138MB. I guess somebody fixed the dependencies (of the npm modules registry), so that some 500MB of stuff is not installed.
There is no react-native in the starter project that you referenced. :)
So, that is not what is causing the large directory.
It is typical to have a large node_modules directory. This directory is usually placed in the .gitignore (or similar) so that it is not committed to the source control repository.
In order to track dependencies, use the --save and --save-dev switches in npm install and make sure to commit your package.json
Also, when you npm install for production, use the npm install --production switch to exclude dev dependencies.
When you run npm install all dependencies will be installed as from package.json,
this includes devDependencies and dependencies (using npm you can also control what to install or not as Davin Tryon pointed out). Below an extract from your package.json you can see all dep included. Also you could consider ignoring node_modules on git or svn to do use space on your repository.
You could consider manually remove the node_modules directory if you do not work on a project so you can save some space on you HD.
"devDependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"chai": "^3.5.0",
"chai-jquery": "^2.0.0",
"jquery": "^2.2.1",
"jsdom": "^8.1.0",
"mocha": "^2.4.5",
"react-addons-test-utils": "^0.14.7",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"babel-preset-stage-1": "^6.1.18",
"lodash": "^3.10.1",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "^4.0.0",
"react-router": "^2.0.1",
"redux": "^3.0.4"
}

npm installing the wrong version

After i execute npm install, i see that the version of the typings is 1.0.3. But in my package.json, i wrote the exacty the verion that i want. Any idea what is going on ?
is npm always trying to install the latest ?
"devDependencies": {
"nodemon": "^1.9.2",
"promise": "^7.1.1",
"request": "^2.72.0",
"require-dir": "^0.3.0",
"typescript": "^1.8.7",
"typings": "^0.7.12"
}
When i run :
typings -v
1.0.3
Try remove the ^ and write only:
"typings": "0.7.12"

Resources