Unable to run NPM in MAC Terminal - npm

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?

Related

Error on any command npm. Error on any command npm

TypeError: invalid options argument at optsArg (/node_modules/mkdirp/lib/opts-arg.js:13:11) at mkdirp (/node_modules/mkdirp/index.js:11:10) at inferOwner.then.owner (/usr/share/npm/node_modules/gentle-fs/lib/mkdir.js:14:5) Error: npm.load() required at Object.get (/usr/share/npm/lib/npm.js:59:13) at process.errorHandler (/usr/share/npm/lib/utils/error-handler.js:205:32) at process.emit (events.js:198:13) at emitPromiseRejectionWarnings (internal/process/promises.js:140:18) at process._tickCallback (internal/process/next_tick.js:69:34) /usr/share/npm/lib/npm.js:59 throw new Error(npm.load() required) ^ Error: npm.load() required at Object.get (/usr/share/npm/lib/npm.js:59:13) at process.errorHandler (/usr/share/npm/lib/utils/error-handler.js:205:32) at process.emit (events.js:198:13) at process._fatalException (internal/bootstrap/node.js:497:27)
What's going on here? I do not understand anything
clean ubuntu focal.
Deleted /node_modules and installed npm via nvm. Now it works.

NPM giving error - TypeError: Cannot destructure property `stat` of 'undefined' or 'null'

when I type npm on cmd, I get error TypeError: Cannot destructure property stat of 'undefined' or 'null'.
Try
npm -v
and check whether npm is showing version or not !
If not then please try to install or if you already installed app then try to add path up to /bin in the environment variable. This will help you.

Upgrading jhipster from v5.0.1 to the latest

I am running linux 18.04, installed java 8. I am struggling with upgrading the current version of jhipster (v5.0.1)to the latest. I have used, yo, yarn and npm but there is no success.
With npm I get an error below, with yo i get the [subsequent] error:
Using JHipster version installed globally Executing jhipster:upgradeOptions:
Welcome to the JHipster Upgrade Sub-Generator
This will upgrade your current application codebase to the latest JHipster version
events.js:174
throw er; // Unhandled 'error' event
^
Error: ERROR! Current directory does not contain a JHipster project.
at Environment.error (/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-environment/lib/environment.js:157:40)
at module.exports.error (/usr/lib/node_modules/generator-jhipster/generators/generator-base.js:1981:18)
at module.exports.assertJHipsterProject (/usr/lib/node_modules/generator-jhipster/generators/upgrade/index.js:144:26)
at Object.<anonymous> (/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:399:25)
at /usr/lib/node_modules/generator-jhipster/node_modules/run-async/index.js:25:25
at new Promise (<anonymous>)
at /usr/lib/node_modules/generator-jhipster/node_modules/run-async/index.js:24:19
at self.env.runLoop.add.completed (/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:400:11)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
Emitted 'error' event at:
at Immediate.setImmediate (/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/lib/index.js:406:18)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
[subsequent]
? Generators to update (Press <space> to select, <a> to toggle all, <i> to invert selection)generator-jhipster
Unhandled rejection Error: EACCES: permission denied, open '/home/lelo/.npm/_cacache/index-v5/ad/54/831265f841b3fd278d23c4c96b06a32656a62c88fddaa7739f419602a04d'
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! /home/lelo/.npm/_logs/2019-08-25T22_22_40_369Z-debug.log```
Despite any user type, I am not getting the expected output which is the upgraded version of jhipster. What could I be doing wrong?
Make sure you are in your application directory and have git installed.
Then execute jhipster upgrade.
You will probably have to solve some problems of the resulting merge arising during the update.
More info: https://www.jhipster.tech/upgrading-an-application/

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 install error EACCES permission denied?

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