npm cannot install some packages globally and locally? - npm

I'm developing some JavaScript application with VSCode editor, and it says cannot find ESlint package. So i tried install it locally on app directory and globally, but both methods are failed. It gives following error(log file) and stops installation.
silly fetchPackageMetaData error for emoji-regex#^7.0.1 Unexpected end of JSON input while parsing near '...gex-7.0.1.tgz","fileC'

i tried to install package that causes the error and it also get failed, i cleared cache of npm with npm cache clean --force and re-install eslint package. And it worked.

Related

TypeError: Cannot read property 'NormalModule' of undefined

I am working on a big project and I cannot run it anymore because of this error:
When I run npm run serve
ERROR TypeError: Cannot read property 'NormalModule' of undefined
TypeError: Cannot read property 'NormalModule' of undefined
at VueLoaderPlugin.apply (/Users/<user>/muso-ninjas/node_modules/vue-loader-v16/dist/pluginWebpack5.js:44:47)
at webpack (/Users/<user>/muso-ninjas/node_modules/#vue/cli-service/node_modules/webpack/lib/webpack.js:51:13)
at serve (/Users/<user>/muso-ninjas/node_modules/#vue/cli-service/lib/commands/serve.js:163:22)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Please help me because I am stuck and I would like to go with my project.
Try this first:
In your project root, run npm install. Maybe someone else on your project has changed/added a dependency, and pulling from your git repo got you the code that relies on this, but won't get you the dependency itself.
If that doesn't fix your issue, try this:
Remove the node_modules folder in your project root.
Update your Node.js version to the latest 16.x version.
2.1 Verify the update has worked by issuing node -v in the terminal.
Update your npm: Run npm i -g npm in the terminal.
3.1 Very the update has worked by issuing npm -v in the terminal.
Run npm install in your project's root folder.
If this doesn't fix your issue, you need to find help from someone else on your team.
As suggested in link from the first comment, I deleted node_modules, replaced the node-sass in package.json with "sass": "^1.26.5" and ran npm install but it didn't work.
Then I repeated the steps and removed package-lock.json as well.
This helped and the app was served properly
npm install webpack#4.39.3 --save

Cannot find module ‘#expo/metro-config’ when trying to start the project with expo cli >= 4.8.0

I recently tried to launch my project on a new computer. I downloaded the source code from its repository and ran npm install to get all the needed packages.
However, when I run npm start or expo start:web, I get the error:
Cannot find module '#expo/metro-config'
I ran npm install #expo/metro-config and the install run without issue, but I still get the “Cannot find module '#expo/metro-config'” error.
The only post I saw regarding this error recommends editing the metro.config.js but I do not use one.
I am on SDK 42, and the project launches fine on my other computer. Any idea what is happening?
FYI, I use to perform this whole operation without any issue until now.
UPDATE:
I ran npm install -g #expo/metro-config and now I get the error Cannot find module 'resolve-from'
So it looks like maybe running npm install -g expo-cli doesn't actually install all the necessary packages? Could it be the issue?
I managed to make it "work" (get other missing packages errors down the line) by reverting to expo-cli 4.7.3. Anything from 4.8.0 and above will cause the error.
Something else is that on a fresh npm install, after running npm install -g expo-cli, if I try to create a project with expo init, I will get the error Error: Cannot find module 'kleur'. Running npm install kleur fix it, but maybe that's also a clue.

How can i solve this vue related issue

Am trying to create a vue project using command line but it is showing this error message:
Error unexpected end ofJSON input while parsing near '....67e12ef","tarball":"h'
Using command line, I created a new project in C directory after which, I installed vue using NPM. After that I try installing #vue/CLI globally using NPM but while installing it the above error sprout out.
Have done npm cache clean --force but still the same error..
It is hard to suggest anything because your question lacks details.
However this error often appears as a problem with npm itself.
Consider cleaning npm's cache with following commands:
npm cache clean --force
npm cache verify
If the problem will still occur, please provide more details.

How do I install react and react-redux onto my project?

Good afternoon,
I am trying to install react and react-redux onto my project, but I keep getting errors that I don't understand.
$ npx create-react-app learn-redux
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Phelps\AppData\Roaming\npm-cache\_npx\13464" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Taylor Phelps\AppData\Roaming\npm-cache\_logs\2020-02-08T20_44_17_568Z-debug.log
Install for [ 'create-react-app#latest' ] failed with code 1
Could not install from "Phelps\AppData\Roaming\npm-cache\_npx\13464" as it does not contain a package.json file.
I am reading the error, but the problem is...that folder does not exist on my computer and I've checked in the terminal for npm and npx and both are installed on my computer. Does anyone have any ideas on why this may be happening and how to fix it?
Thank you.
According to this Github issue npx has trouble running on Windows if the user has a space in their name and from the error message I'd guess that is the case here. One of the suggested fixes is to set your npm-cache path to a folder without a space in it:
npm config set cache C:\tmp\nodejs\npm-cache --global
Then try running your command again.
Install the project in another directory except C partition :
npx create-react-app learnredux
Then :
npm i react-redux --save
This should work.
The problem is the npm cache by the path of the error. Try running:
npm cache verify
Verify the contents of the cache folder, garbage collecting any
unneeded data, and verifying the integrity of the cache index and all
cached data.
(from https://docs.npmjs.com/cli-commands/cache.html)

NPM `EACCES` error, not fixed by changing the default directory

I was getting an EACCES error from NPM so I followed these directions to fix it by changing the default directory: https://docs.npmjs.com/getting-started/fixing-npm-permissions Using the test they gave at the end, I installed jshint globally without error.
However, when I try to build an Angular project
sudo ng new ProjectName --style=scss --routing
I get a lot of errors, the first one being
Unable to save binary /home/addem/Web/ExplainAngular/node_modules/node-sass/vendor/linux-x64-57 : { Error: EACCES: permission denied, mkdir '/home/addem/Web/ExplainAngular/node_modules/node-sass/vendor'
I then followed these instructions: Error: EACCES: permission denied
Still doesn't fix the problem, so at this point I'm not sure what to do.
I discovered the cause. I had installed the Angular CLI before I followed the fixes above, and therefore the Angular CLI did not have all the ... "stuff" it needed. I guess maybe dependencies or packages. Anyway, after doing the above fixes and then running
npm install -g #angular/cli
I can now create the project without errors.