npm install error EACCES permission denied? - npm

I have permission problem using npm.
When I write "npm install"
Error: EACCES: permission denied, mkdir '/ItsMe'
TypeError: Cannot read property 'get' of undefined
at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:211:17)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:83:20
at cb (/usr/local/lib/node_modules/npm/lib/npm.js:215:22)
at /usr/local/lib/node_modules/npm/lib/npm.js:253:24
at /usr/local/lib/node_modules/npm/lib/config/core.js:81:7
at Array.forEach (native)
at /usr/local/lib/node_modules/npm/lib/config/core.js:80:13
at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:178:20)
at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:235:20)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:211
if (npm.config.get('json')) {
^
TypeError: Cannot read property 'get' of undefined
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:211:17)
at emitOne (events.js:96:13)
at process.emit (events.js:191:7)
at process._fatalException (bootstrap_node.js:304:26)
With a "ls -l" I have rwx rights.
I don't understand what "Cannot read property 'get' of undefined" means.
I searched on the web and tried several things but it' doesn't work.
Could you help me ?
Thank you

Your npm install try to do an mkdir in a file you don't have access to. Try to give him the right by doing
sudo npm install
or doing it as a super user (I dont recomand that) You also asked what npm install do without argument. Well if ou don't specify a folder it creates the folder node_module (that is why it does an mkdir). If you don't precise a module it will install all the module from package.json. It can take morte time and you will have a lots of package you won't need but with that you will be sure to have the one you want.
You can choose the package you want if you exactly know wich one. ie :
npm install sax#latest
the latest mean it gonna search for the last existing package
ANd you can also install a package you downloaded yourself. ie :
npm install ./package.tgz

Related

ERROR TypeError: Cannot read property 'version' of undefined Vue.js

When I run npm start
I get
ERROR TypeError: Cannot read property 'version' of undefined
TypeError: Cannot read property 'version' of undefined
This happens after I have run
npm install
I tried to solve the issue by running npm -g install npm#version but instead it gave me this error
npm ERR! code ETARGET
npm ERR! notarget No matching version found for npm#version.
Did you just upgrade your dependencies directly from 3.0?
In v4 eslint is required as a dependency of the project itself.
So npm install --save-dev eslint#4 may fix the warning.
From my experience it may happen if there is import of package.json in one of your project's files, but with incorrect path.
Usually, some build related configurations use version property of the package.json.
It is hard to pinpoint the exact issue, since no specifics provided.
First, I'd search stack trace of the error to locate which file is requesting package.json. Global project search for .version should help to find the issue as well.
If you still unable to locate the issue, please, add full error stack trace.

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

Unable to run NPM in MAC Terminal

Unable to run npm in mac, tried un-installing re-installing it. (Removed the NPM properly and re-installed it). But every time I am getting below error.
Error: EEXIST: file already exists, mkdir '/usr/local/bin/npm'
TypeError: Cannot read property 'loaded' of undefined
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98:27)
at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:77:20
at cb (/usr/local/lib/node_modules/npm/lib/npm.js:225:22)
at /usr/local/lib/node_modules/npm/lib/npm.js:263:24
at /usr/local/lib/node_modules/npm/lib/config/core.js:83:7
at Array.forEach (<anonymous>)
at /usr/local/lib/node_modules/npm/lib/config/core.js:82:13
at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:173:20)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
TypeError: Cannot read property 'loaded' of undefined
at exit (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:98:27)
at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:216:3)
at process.emit (events.js:196:13)
at process._fatalException (internal/process/execution.js:146:25)
When I type NPM, it should run, instead I am getting above error.
It appears to be related to user permissions. See this post: npm error on every command: EEXIST: file already exists, mkdir 'c:\users\user\appdata\Roaming\npm'. Are you running the npm command as root?

Unhandled rejection error: invalid config key requested when attempting to update Cypress via NPM

I am trying to update Cypress to the latest version using the following provided command:
npm install --save-dev cypress#3.2.0
In previous versions this has worked fine with no errors. Now, when I run this, I keep getting the following error:
Unhandled rejection Error: invalid config key requested: agentn 099cbf610e4ce787
at BadKeyError (/usr/local/lib/node_modules/npm/node_modules/figgy-pudding/index.js:93:23)
at pudGet (/usr/local/lib/node_modules/npm/node_modules/figgy-pudding/index.js:101:5)
at FiggyPudding.get (/usr/local/lib/node_modules/npm/node_modules/figgy-pudding/index.js:27:12)
at Object.get (/usr/local/lib/node_modules/npm/node_modules/figgy-pudding/index.js:159:16)
at new PacoteOptions (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/util/opt-check.js:9:21)
at optCheck (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/util/opt-check.js:63:10)
at Object.manifest (/usr/local/lib/node_modules/npm/node_modules/pacote/manifest.js:11:10)
at fetchPackageMetadata (/usr/local/lib/node_modules/npm/lib/fetch-package-metadata.js:58:10)
at limited (/usr/local/lib/node_modules/npm/node_modules/call-limit/call-limit.js:29:10)
at /usr/local/lib/node_modules/npm/lib/install/deps.js:235:14
at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:35
at Array.forEach (<anonymous>)
at /usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:52:11
at Array.forEach (<anonymous>)
at asyncMap (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:51:8)
at exports.getAllMetadata (/usr/local/lib/node_modules/npm/lib/install/deps.js:206:3)
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jaswindersingh/.npm/_logs/2019-03-15T13_32_13_190Z-debug.log
Could anyone point me to what this means and how I can fix it?
Never seen this kind of error before?
And as far as I know I've not made any changes to any of my packages in either package.json or package-lock.json etc (from what I have read so far from similar posts)
I think this is an npm issue.
Try to delete package-lock.json and run your command again. This should solve your problem.
Also, if you can, try to upgrade your npm version, since this issue is marked as closed in npm repository.
It is really npm issue. Try to change version to some up-to-date one. If there is some problems with it, you can use nvm.
In my case I`ve changed node version 10.8.0 to 12.18.3 and npm as well.

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.