Unable to install a npm package and dependency - javascript

I'm trying to adapt an external API named cric-live into my node application for displaying cricket scores in my application. When I try to install the dependency, it shows an error as below
PS F:\Node Express\NodeJS\cric api> npm i cric-live
npm ERR! Unexpected end of JSON input while parsing near '...":"request-promise","'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Thiluxan\AppData\Roaming\npm-cache\_logs\2020-07-01T04_51_42_400Z-debug.log
This is the source link for the dependency I'm trying to install
https://www.npmjs.com/package/cric-live?activeTab=readme

Your npm cache maybe busted so I would say run this code first and try installing the package again
npm cache clean --force

Related

why i can not create a new react app with npm?

im going to create a new react app with npm , but it dos'nt work and i have too many errors each time i try
can someone help me please?:(
i entered this line in cmd
npx create-react-app my-app
and the errors :
npm ERR! code ECONNRESET
npm ERR! syscall read
npm ERR! errno -4077
npm ERR! network read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sobha\AppData\Local\npm-cache\_logs\2022-11-29T11_57_33_191Z-debug-0.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting my-app/ from C:\Users\sobha\Desktop\react
Done.
Firstly Check your network connection and then
npm cache clean --force
npm create react-app
The problem could easily be you are being blocked to that website by your ISP's or Company's firewall/proxy. Using the above method is quicker and easier but it's also insecure as it doesnt verify you are connected to the right website. To check if you are being blocked simply go to registry.npmjs.org in your browser. You should get some text back.
Option 1
Try this:
npm config set registry http://registry.npmjs.org/
so that npm requests for http url instead of https.
and then try the same npx create-react-app my-app command.
Option 2
You may also want to check your NPM proxy settings and perhaps remove it.
npm config get proxy
npm config rm proxy
npm config rm https-proxy

create-react-app aborting with code ENOENT

Just started out with React using an online course from Udemy. For some reason my create-react-app stopped working all of a sudden and it shows this log.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize
npm ERR! dest C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize' -> 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Vahram\AppData\Roaming\npm-cache\_logs\2021-05-06T21_38_53_463Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting pokedex-exercise/ from C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5
Done.
I checked out similar questions on here and there were some solutions I tried. The usual answer is to delete package.json but I don't have that seeing as I'm trying to make a new React app. Here's what I've tried so far:
Originally tried npx create-react-app my_app
Then tried running npm install -g create-react-app and then create-react-app my_app.
Then tried npm cache clean --force followed by npm rebuild then step 2 again.
Then tried npm init --yes to generate a package.json file, followed by trying to make a new app again using CRA.
Tried restarting the machine
Curious thing I noticed that I'm not sure is related to the issue:
When I go to Task Manager, there are two Node.js processes running. When I try to end one, it spawns another Node.js process... I can't get rid of all Node.js processes. This is why I originally restarted the machine.
Any help is appreciated! I have no idea how to proceed... I'm even thinking of formatting my machine and starting everything from scratch. However, I'd like to know why this happens so that I can avoid it in the future.
I just solved this using the following command.
npm uninstall -g create-react-app
and then:
npm install -g create-react-app
Regards

ENOLOCK npm ERR! Error while running npm audit fix

I am trying to install GLOBALLY a package with npm from my home directory. After the install has completed, it indicates vulnerabilities. Upon trying to run npm audit fix, I obtain the following error.
npm ERR! code ENOLOCK npm ERR! audit This command requires an existing
lockfile. npm ERR! audit Try creating one first with: npm i
--package-lock-only npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
I understand that the error asks me to run npm i --package-lock-only, but in which directory should I be creating this file? Running the command without specifying a path does not work. I have also tried to create the file in the directory where the package was installed, but that has also not solved the issue. Also, why isn't this file present to start with?
npm audit fix is intended to fix vulnerabilities with the dependencies of your own project. Projects do have a package-lock.json file.
It is not intended for globally installed packages. If there are vulnerabilities with packages from others, they need to be fixed by the package maintainer in a new release. You can then update to this new release.
BTW, you should not use globally installed packages. Use npx instead.

I have been trying to install or create a react app but I kept getting this error message

I have been trying to install or create a react app but I kept getting this error message
" npm ERR! Unexpected end of JSON input while parsing near '...5VmmIPyPaAPmy1Iv3blBY'"
Also:
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Madu Emmanuel IP\AppData\Roaming\npm-cache_logs\2020-10-13T11_40_59_715Z-debug.log
Go to your Command Prompt, cd into the desired folder and write:
npm i -g create-react-app
Once done, write:
npx create-react-app <project-name>
It should work perfectly.

React keeps aborting installation when I try the tutorial

I was trying to follow the tutorial on the react website today but for whatever reason it doesnt want to work for me when i run the command:
npx create-react-app my-app
`I get the following error message;
Creating a new React app in D:\NodeJs\react\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! code ETARGET
npm ERR! notarget No matching version found for postcss#^7.0.11
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'autoprefixer'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\matth\AppData\Roaming\npm-cache\_logs\2019-01-
12T17_55_39_805Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-
scripts has failed.
Deleting generated file... package.json
Deleting my-app/ from D:\NodeJs\react
Done.`
My npm version is 6.5.0 and Node is 11.6.0
Not sure what the heck is going on as when I did this on my work laptop it worked without any issues with the exact same versions of node and npm
I was fix problem when I error create-react-app
Err: code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
I had rename file .npmrc --> .npmrc-old
C:\Users\you\.npmrc
And I success >>> I feel perfect
-
Or can you fix:
--> use git bash terminal
Just an update for everyone. It worked now. All I did was reinstall nodejs for the 4th time, nothing else. Makes 0 sense. anyways, thanks for your answers, appreciate it.
I also got a same error.
Try to run npm cache clean --force after that just run create-react-app
Definitely It will work

Categories