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

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.

Related

Error "Cannot read property "matches" of undefined" when using "npm install"

I'm trying to install expo globally on my Windows 10 machine for a school assignement.
As the doc says, I've been trying the following command in my terminal :
$ npm install --global expo-cli
but it always gives me the same error :
npm ERR! Cannot read property 'matches' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Local\npm-cache\_logs\2021-04-07T13_43_16_562Z-debug.log
I've tried running $ npm install -g expo-cli instead but the same thing happens.
I haven't tried reinstalling node or anything yet because I need my pc up and running for this week and I'm not too accustomed to all that, I'd like to keep that a last resort if possible.
Has anyone ever encountered this error before ?
Thanks to those who replied but I "accidentally" fixed it myself.
Through my searching I ended up actually uninstalling node with $ nvm uninstall v15.0.0 and I found myself obligated to download it again here.
Must've been a problem with the version I was using as suggested before.
Try removing the node_modules folder and package-lock.json file and run command npm install.

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 permission error installing modules for material design

So, I really want to get started using material design. I'm using their getting started guide (https://material.io/develop/web/docs/getting-started/). Everything worked until the part where I have to install the modules. There I got the error:
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/paul/Code/Material_Design_Test/Test4/node_modules/node-sass/build'
And then because of this the npm start command did not work either.
I've tried running it with sudo, same error. Tried to give me ownership of the folders, as sudo. Nothing worked.
you may run with sudo mode or else give the folder ownership with your user account and try to run it again
chown -R yourusername:yourusername directory

npm cannot install some packages globally and locally?

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.