npm install fails with "Cannot find module 'glob'" - node.js

Here is the output on the console:
floydpink#MBP mean-app (master) $ npm install
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.32
npm ERR! npm v2.0.0
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'glob'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/floydpink/Source/swara-server/mean-app/npm-debug.log
floydpink#MBP mean-app (master) $
And the npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install' ]
2 info using npm#2.0.0
3 info using node#v0.10.32
4 verbose node symlink /usr/local/bin/node
5 verbose stack Error: Cannot find module 'glob'
5 verbose stack at Function.Module._resolveFilename (module.js:338:15)
5 verbose stack at Function.Module._load (module.js:280:25)
5 verbose stack at Module.require (module.js:364:17)
5 verbose stack at require (module.js:380:17)
5 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/completion/file-completion.js:5:12)
5 verbose stack at Module._compile (module.js:456:26)
5 verbose stack at Object.Module._extensions..js (module.js:474:10)
5 verbose stack at Module.load (module.js:356:32)
5 verbose stack at Function.Module._load (module.js:312:12)
5 verbose stack at Module.require (module.js:364:17)
6 verbose cwd /Users/floydpink/Source/swara-server/mean-app
7 error Darwin 13.4.0
8 error argv "node" "/usr/local/bin/npm" "install"
9 error node v0.10.32
10 error npm v2.0.0
11 error code MODULE_NOT_FOUND
12 error Cannot find module 'glob'
13 error If you need help, you may report this error at:
13 error <http://github.com/npm/npm/issues>
14 verbose exit [ 1, true ]
I upgraded to this version of nodejs and npm a few days back and things have been fine until yesterday.
Could someone point me to the right direction in fixing this?

I faced the exact issue. But I did not have brew on my Ubuntu Amazon EC2 instance(and I did not want to install it). I uninstalled npm using sudo npm uninstall npm –g and then ran the make install command again in the NPM directory to recompile npm and that fixed the issue.

In my case, my Node.js was installed by the .pkg file(On a macOS). And tried reinstall npm but failed.
I solved this problem by uninstall the node totally follow this gist: https://gist.github.com/TonyMtz/d75101d9bdf764c890ef

Related

Can't update npm - npm ERR! Cannot find module 'update-notifier'

I can't do npm install on Windows in my application in Angular 8, because I get error:
C:\Repository\Tools\Tools\ClientApp>npm install
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'update-notifier'
npm ERR! Require stack:
npm ERR! - C:\Users\xxx\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxx\AppData\Roaming\npm-cache\_logs\2021-02-19T13_09_42_358Z-debug.log
in log file:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install'
1 verbose cli ]
2 info using npm#6.14.11
3 info using node#v14.15.5
4 verbose stack Error: Cannot find module 'update-notifier'
4 verbose stack Require stack:
4 verbose stack - C:\Users\xxx\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
4 verbose stack at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
4 verbose stack at Function.Module._load (internal/modules/cjs/loader.js:725:27)
4 verbose stack at Module.require (internal/modules/cjs/loader.js:952:19)
4 verbose stack at require (internal/modules/cjs/helpers.js:88:18)
4 verbose stack at EventEmitter.<anonymous> (C:\Users\xxx\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:87:22)
4 verbose stack at processTicksAndRejections (internal/process/task_queues.js:75:11)
5 verbose cwd C:\Repository\Tools.xxx\Tools.xxx\ClientApp
6 verbose Windows_NT 10.0.17763
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
8 verbose node v14.15.5
9 verbose npm v6.14.11
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'update-notifier'
11 error Require stack:
11 error - C:\Users\xxx\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
12 verbose exit [ 1, true ]
Any other command that I try to call causes the same result, for example:
npm i -g npm-upgrade
npm cache clean
npm install -g update-notifier
Error occured when I try to update npm to version 7. Now I uninstall version 7 and there is version 6.14.11 as it was at the begin, but I still can't call npm install
I uninstalled Node.js and installed again but didn't help
In folder:
C:\Users\xxx\AppData\Roaming\npm\node_modules\npm
I have package.json file and inside this file:
"bin": {
"npm": "./bin/npm-cli.js",
"npx": "./bin/npx-cli.js"
},
"dependencies": {
"update-notifier": "^2.5.0",
I tried to remove this line but result is the same, cannot find module update-notifier
I found solution in this question:
npm-cli-js-not-found
Copy the directory named npm from your installed node path (In my case the npm directory was available in C:\Program Files\nodejs\node_modules).
Navigate to C:\Users\%USERNAME%\AppData\Roaming\npm\node_modules and paste the copied npm directory there.

Unable to install/ uninstall anything using npm

I'm working through a tutorial about learning npm, but am having trouble with even the simplest instructions.
Basically the first instruction given was to install the node-dev package globally, using the Terminal line: sudo npm install -g node-dev. Unfortunately, this spits out an error:
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './access-error.js'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/samlegros/.npm/_logs/2019-02-26T00_36_39_572Z-debug.log
After some Googling and digging, nothing seemed to work for my case. So I thought I would try fully removing and reinstalling npm to start with a clean slate (I had worked with npm a while back, so maybe something messed up back then).
Even going through the official npm-removal documentation, I still get a similar error! I can't even remove npm properly...
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './access-error.js'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/samlegros/.npm/_logs/2019-02-26T00_38_40_865Z-debug.log
Any help would be deeply appreciated. I've tried several npm tutorials over the months and they always result in errors that I just never know how to overcome, very discouraging :(
(error log, if that helps)
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'uninstall',
1 verbose cli 'npm',
1 verbose cli '-g' ]
2 info using npm#6.8.0
3 info using node#v8.11.1
4 verbose stack Error: Cannot find module './access-error.js'
4 verbose stack at Function.Module._resolveFilename (module.js:547:15)
4 verbose stack at Function.Module._load (module.js:474:25)
4 verbose stack at Module.require (module.js:596:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/install/exists.js:4:19)
4 verbose stack at Module._compile (module.js:652:30)
4 verbose stack at Object.Module._extensions..js (module.js:663:10)
4 verbose stack at Module.load (module.js:565:32)
4 verbose stack at tryModuleLoad (module.js:505:12)
4 verbose stack at Function.Module._load (module.js:497:3)
4 verbose stack at Module.require (module.js:596:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/install/check-permissions.js:8:14)
4 verbose stack at Module._compile (module.js:652:30)
4 verbose stack at Object.Module._extensions..js (module.js:663:10)
4 verbose stack at Module.load (module.js:565:32)
5 verbose cwd /path/to/tutorial/
6 verbose Darwin 18.2.0
7 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "uninstall" "npm" "-g"
8 verbose node v8.11.1
9 verbose npm v6.8.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module './access-error.js'
12 verbose exit [ 1, true ]
I simply removed Node.js from my Mac and reinstalled it, that worked.
Command used to remove Node.js: sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
Everything works great now.

npm ERR! Cannot find module 'spdx-expression-parse'

This error occurred while command npm run watch was in process, I tried to solve it with different tactics but can't find any solution
Steps which I tried to resolve the issue
1) Remove node module, package-lock.json, yarn.lock npm cache clear and the run npm install but error still occurs.
2) Remove nodejs from control panel and reinstall with latest and then old/previous version and the reinstall but can't succeed, error still occurs.
npm ERR! code MODULE_NOT_FOUND npm ERR! Cannot find module
'spdx-expression-parse'
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\DELL\AppData\Roaming\npm-cache_logs\2018-12-20T08_00_01_749Z-debug.log
Log File
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\DELL\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm#6.5.0
3 info using node#v8.12.0
4 verbose stack Error: Cannot find module 'spdx-expression-parse'
4 verbose stack at Function.Module._resolveFilename (module.js:548:15)
4 verbose stack at Function.Module._load (module.js:475:25)
4 verbose stack at Module.require (module.js:597:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (C:\Users\DELL\AppData\Roaming\npm\node_modules\npm\node_modules\validate-npm-package-license\index.js:1:75)
4 verbose stack at Module._compile (module.js:653:30)
4 verbose stack at Object.Module._extensions..js (module.js:664:10)
4 verbose stack at Module.load (module.js:566:32)
4 verbose stack at tryModuleLoad (module.js:506:12)
4 verbose stack at Function.Module._load (module.js:498:3)
5 verbose cwd D:\it-88-lynx
6 verbose Windows_NT 10.0.17134
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\DELL\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
8 verbose node v8.12.0
9 verbose npm v6.5.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'spdx-expression-parse'
12 verbose exit [ 1, true ]
Atlast, I have solved the problem, the spdx-expression-parse has been corrupted located in users/AppData/Roaming/npm/node_modules/
remove node_modules
uninstall nodejs
(Start Main Step)
Go to users/AppData/Roaming and delete npm and npm-cache folders manually
(End Main Step)
then run following command
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
thanks for all your suppport.

Can't update node: npm does not support Node.js v5.3.0

I am using MacOS Sierra v10.12.6, I have written the command npm update -g and got the result
npm WARN npm npm does not support Node.js v5.3.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Buffer.alloc is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/demiryil/.npm/_logs/2017-11-21T08_43_54_258Z-debug.log
The logs printed out
0 info it worked if it ends with ok
1 warn npm npm does not support Node.js v5.3.0
2 warn npm You should probably upgrade to a newer version of node as we
3 warn npm can't make any promises that npm will work with this version.
4 warn npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
5 warn npm You can find the latest version at https://nodejs.org/
6 verbose cli [ '/usr/local/Cellar/node/5.3.0/bin/node',
6 verbose cli '/usr/local/bin/npm',
6 verbose cli 'update',
6 verbose cli '-g' ]
7 info using npm#5.5.1
8 info using node#v5.3.0
9 verbose stack TypeError: Buffer.alloc is not a function
9 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/tar/lib/pack.js:32:20)
9 verbose stack at Module._compile (module.js:398:26)
9 verbose stack at Object.Module._extensions..js (module.js:405:10)
9 verbose stack at Module.load (module.js:344:32)
9 verbose stack at Function.Module._load (module.js:301:12)
9 verbose stack at Module.require (module.js:354:17)
9 verbose stack at require (internal/module.js:12:17)
9 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/tar/lib/create.js:6:14)
9 verbose stack at Module._compile (module.js:398:26)
9 verbose stack at Object.Module._extensions..js (module.js:405:10)
9 verbose stack at Module.load (module.js:344:32)
9 verbose stack at Function.Module._load (module.js:301:12)
9 verbose stack at Module.require (module.js:354:17)
9 verbose stack at require (internal/module.js:12:17)
9 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/tar/index.js:4:30)
9 verbose stack at Module._compile (module.js:398:26)
10 verbose cwd /Users/demiryil/Documents/JS projects/katanio
11 verbose Darwin 16.7.0
12 verbose argv "/usr/local/Cellar/node/5.3.0/bin/node" "/usr/local/bin/npm" "update" "-g"
13 verbose node v5.3.0
14 verbose npm v5.5.1
15 error Buffer.alloc is not a function
16 verbose exit [ 1, true ]
After searching for a while I found that this command worked for people sudo npm uninstall -g npm, however I get the exact same error when trying to uninstall npm.
So how can I update my npm?
The Node.js version 5.3.0 that you are using is severely outdated. You have installed the latest npm version (5.5.1), but this is the package manager and it does not run on such an outdated Node.js, because it relies on features that have been added later. As you can see in the error message, it uses Buffer.alloc, which did not exist in that version.
You need to upgrade your Node.js (the runtime), not npm (the package manager). When you run npm update -g it only updates the packages which have been installed by npm.
It looks like you have installed Node.js with Homebrew, so you can upgrade it with the following commands:
brew update
brew upgrade node

How to solve error: Cannot find module 'json-parse-helpfulerror'

In Windows, I tried to create a new application form of this site: https://facebook.github.io/react/docs/installation.html
First, I installed Node.js v8.2.1 and when I execute npm install -g create-react-app, I get the following error:
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'json-parse-helpfulerror'
npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\mushou8\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'create-react-app' ]
2 info using npm#5.2.0
3 info using node#v6.11.2
4 verbose stack Error: Cannot find module 'json-parse-helpfulerror'
4 verbose stack at Function.Module._resolveFilename (module.js:469:15)
4 verbose stack at Function.Module._load (module.js:417:25)
4 verbose stack at Module.require (module.js:497:17)
4 verbose stack at require (internal/module.js:20:19)
4 verbose stack at Object.<anonymous> (C:\Users\mushou8\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:12:16)
4 verbose stack at Module._compile (module.js:570:32)
4 verbose stack at Object.Module._extensions..js (module.js:579:10)
4 verbose stack at Module.load (module.js:487:32)
4 verbose stack at tryModuleLoad (module.js:446:12)
4 verbose stack at Function.Module._load (module.js:438:3)
5 verbose cwd C:\Users\mushou8
6 verbose Windows_NT 6.1.7601
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mushou8\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "create-react-app"
8 verbose node v6.11.2
9 verbose npm v5.2.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'json-parse-helpfulerror'
12 verbose exit [ 1, true ]
In the directory folder, issue the following command:
npm update
Remove npm and reinstall it
And run:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
Seeing what is requested in the Users folder, it seems that it should be installed as a global package.
Check and install each required package.
npm i -g json-parse-helpfulerror
You must uninstall nodejs and npm packages.
after first, you must install npm.
and you should install "npm install --save json-parse-better-errors"
Finally you can run your project
https://www.npmjs.com/package/json-parse-better-errors
I fixed it by removing the node_modules folder and reinstalling it again. To remove the folder, go to your project folder and run $ rm -rf node_modules and then reinstall your packages using your preferred package manager, either npm i or yarn install.

Resources