Nodemon: Error: Cannot find module 'internal/util/types'

Created on 30 Oct 2017  ·  63Comments  ·  Source: remy/nodemon

This is what I get when running nodemon with no arguments.

exception in nodemon killing node
Error: Cannot find module 'internal/util/types'
    at Function.Module._resolveFilename (module.js:513:15)
    at Function.Module._load (module.js:463:25)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at evalmachine.<anonymous>:31:26
    at Object.<anonymous> (/usr/local/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/configstore/node_modules/graceful-fs/fs.js:11:1)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)

I'm using node 8.8.1

Most helpful comment

I have solved it in this way:

sudo npm cache clean
sudo n 6.12.0
sudo npm uninstall npm -g
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
//if you are using a raspberry with node-red installed run this command to reinstall npm and node
update-nodejs-and-nodered 
//OR run this command to reinstall manually
sudo apt install nodejs npm

All 63 comments

Ah looks like node v8.2.1 works.

I had the same issue. When i reverted to the older version of node js,the problem got solved.

Still happening in v8.9.0.

npm ERR! Cannot find module 'internal/util/types'

Although nodejs seemed to install without errors.

I've dropped down to v8.2.1 and still hit the same issues:

xxx@xxx~/Programs/xxx.telegram.bot$ nvm alias default 8.2.1
default -> 8.2.1 (-> v8.2.1)
xxx@xxx:~/Programs/xxx.telegram.bot$ cd /home/munkee/Programs/xxx.telegram.bot ; env "NODE_ENV=development" /usr/bin/nodemon --inspect=13845 --debug-brk index.js
exception in nodemon killing node
Error: Cannot find module 'internal/fs'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at evalmachine.<anonymous>:40:20
    at Object.<anonymous> (/usr/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/configstore/node_modules/graceful-fs/fs.js:11:1)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)

----------------------------------------------------------
If appropriate, please file an error with the output from:
$ /home/munkee/.nvm/versions/node/v8.2.1/bin/node /usr/bin/nodemon --inspect=13845 --debug-brk index.js --dump
At http://github.com/remy/nodemon/issues/new
----------------------------------------------------------

I had this issue, I fixed it by dropping down my node version (to 6.2.2 in my case), updating npm, and then going back to Node v9.0.0.

I'm using nvm I'm wondering if I need to clear out remove something after dropping down the versions of node to then run the npm update. I've tried just dropping and running the update but I still get the same error.

I found the cause of the problem.This problem occurs if the default path of the command line is set in the registry again

How do you fix that? 😂
I'm using ubuntu fwiw

On Thu, 9 Nov 2017, 08:07 ifredom, notifications@github.com wrote:

I found the cause of the problem.This problem occurs if the default path
of the command line is set in the registry again


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/remy/nodemon/issues/1124#issuecomment-343077326, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABXXNFH2xvmsCGSeWjZ-asdA5ndnQe1Vks5s0rLNgaJpZM4QLuLN
.

I fixed it like this (Windows):
It turned out I had an old version of npm.exe in C:\ProgramData\chocolateybin
Just run npm.exe install -g npm and it fixed it

Same for v8.9.1, when trying to install angular CLI:

D:\playground\ng>npm install -g @angular/cli@latest
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "-g" "@angular/cli@latest"
npm ERR! node v8.9.1
npm ERR! npm v3.7.1
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'internal/util/types'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! D:\playground\ng\npm-debug.log

I think it is realated to:
https://github.com/npm/npm/issues/19032 and it is closed. For me this helped.

On Windows, this is how it sorted out:

  1. Go to \global_modules\node_modules,

  2. Delete the "npm" folder and all its contents,

  3. Go to https://nodejs.org,

  4. Download the "Recommended For Most Users" version (currently 8.9.1 LTS),

  5. Install it

This worked for me on Win7.

Anyone have instructions for Ubuntu. I would assume same deal remove node
modules and start over?👊👍

On Sun, 12 Nov 2017, 17:22 aromot, notifications@github.com wrote:

On Windows, this is how it sorted out:

1.

Go to \global_modules\node_modules,
2.

Delete the "npm" folder and all its contents,
3.

Go to https://nodejs.org,
4.

Download the "Recommended For Most Users" version (currently 8.9.1
LTS),
5.

Install it

This worked for me on Win7.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/remy/nodemon/issues/1124#issuecomment-343752571, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABXXNP9XRxVSsmFaapv8aZ4kTUeRBsg5ks5s1ylegaJpZM4QLuLN
.

After upgrade to OS X 10.13.1 it started failing.

brew upgrade node - fixed the issue

I am having the same issue on Mac. My tests are failing.

Error: Cannot find module 'internal/util/types'

node version : v8.9.1
npm : 5.5.1

Any help would be appreciated.

@mmilenkovic
whats your node version?

I'm running OS X 10.13.1 and node 8.9.1 but still having this issue

@wema1043

node version : v8.9.0
npm : 5.5.1

got it with Node v6.2.2

I solved it by reinstalling nodejs.

I have solved it in this way:

sudo npm cache clean
sudo n 6.12.0
sudo npm uninstall npm -g
rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/npm*
//if you are using a raspberry with node-red installed run this command to reinstall npm and node
update-nodejs-and-nodered 
//OR run this command to reinstall manually
sudo apt install nodejs npm

Having the same issue on windows 8.1 with node 8.9.1 and 9.2.0. Downgrading to node 6.12 solves the problem. Complete uninstall/installs don't. How can possibly a stable node version be released like that?

I solved this by reinstalling bower. And running bower install

Closing. This seems to be related to cached node_modules between version changes.

For those who're facing this issue on ionic projects after updating to Mac Sierra 10.13, know that the problem is with ionic CLI (v1.7.16). I was facing issue while creating builds using the normal ionic command
ionic build android
and I was getting

Error: Cannot find module 'internal/util/types'
    at Function.Module._resolveFilename (module.js:542:15)
    at Function.Module._load (module.js:472:25)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at evalmachine.<anonymous>:31:26
    at Object.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:11:1)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)

Cannot find module 'internal/util/types' (CLI v1.7.16)

The solution is, instead of using ionic commands, use the cordova commands directly, like,
cordova build android
Hope that helps someone.

@eternalsayed same problem here, same workaround!

Could you resolve how to do ionic serve?

I'm using ionic serve with --nolivereload and besides it is showing me following warning, it is not failing:

✗ (node:733) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

@eternalsayed didn't work for me (in High Sierra), same output:

ionic serve --nolivereload

Error: Cannot find module 'internal/util/types'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at evalmachine.<anonymous>:31:26
    at Object.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:11:1)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)

Cannot find module 'internal/util/types' (CLI v1.7.16)

Your system information:

Cordova CLI: 6.5.0
Gulp version:  CLI version 1.4.0
Gulp local:   Local version 3.9.1
Ionic CLI Version: 1.7.16
Ionic App Lib Version: 0.7.3
ios-deploy version: 1.9.2
ios-sim version: 6.1.2
OS: Mac OS X El Capitan
Node Version: v8.9.1
Xcode version: Xcode 9.1 Build version 9B55

It was working for me because I hadn't stopped my ionic serve during all of my hunt for solution, but it is failing for me too now. That makes the two of us with the issue.
Let me know if you find a work around for ionic serve now. :(

Okay, so what I did to fix my issue is, uninstalled my ionic-cli and installed the latest version. That fixed the issues.
Do note that in latest version of ionic, commands execute with ionic cordova instead of ionic only, with exception of ionic serve.

npm uninstall -g ionic-cli
npm install -g ionic@latest

I was able to solve this issue for me by deleting package-lock.json and rebuilding the node modules for my project.

I had this issue using the latest version of node and my solution was changed Node to the version 6.12.1 later I uninstalled ionic and Cordova for then installed again.

Ubuntu 17.04
Node v8.9.1

This was occurring to me when i tried to run my gulp scripts. I did few things, not really sure which one in particular solved it, but this is what i did:

sudo npm cache clean --force
sudo npm i -g npm

Then i deleted my node_modules in my project and after the npm i everything worked.

i had this issue in my Win8.1 box; was going from
[email protected] and [email protected]
to
[email protected] and [email protected]

solved it by these steps:
delete C:\Users\<user>\AppData\Roaming\npm\node_modules\npm
run npm install -g npm

If anyone wants to add this workaround to the FAQ, I'd be happy to merge and I'm certain future users will be thankful to you.

Raised a PR for the same. Please merge.

This issue still persists with npm version 5.1.1 and stable node.
The FAQ suggestion would still yield _Cannot find module 'internal/util/types_
The only thing which worked in my case was to fall back to an earlier node version (6.3.1), use npm that comes with it (3.10.3) to install any dependencies and forward back to the stable.

Don't we think this is an issue with npm?

On Mon, 18 Dec 2017, 16:21 Joey Toppin, notifications@github.com wrote:

This issue still persists with npm version 5.1.1 and stable node.
The FAQ suggestion would still yield Cannot find module
'internal/util/types

The only thing which worked in my case was to fall back to an earlier node
version (6.3.1), use npm that comes with it (3.10.3) to install any
dependencies and forward back to the stable.


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/remy/nodemon/issues/1124#issuecomment-352476766, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAA1hEFEL91Ga-hQntcmiCihl1CebsQIks5tBpEbgaJpZM4QLuLN
.

Downgraded to Node 6.12.3 and it worked

having this problem after fresh install of Node 8.9.4 from sources (over previously installed 6.9.x), on Ubuntu 14.04:

ickolay@outpost:~$ sudo npm install -g node-gyp                                                                                                                                                                                                         
[sudo] password for nickolay:                                                                                                                                                                                                                            
npm ERR! code MODULE_NOT_FOUND                                                                                                                                                                                                                           
npm ERR! Cannot find module 'internal/util/types'                                                                                                                                                                                                        

npm ERR! A complete log of this run can be found in:                                                                                                                                                                                                     
npm ERR!     /home/nickolay/.npm/_logs/2018-01-15T12_14_28_012Z-debug.log 

https://github.com/remy/nodemon/blob/master/faq.md#error-cannot-find-module-internalutiltypes this isn't a nodemon issue, it's npm, but others have had success with that faq item.

I had this issue,I fixed it by dropped down my node version to 6.12.0

removing C:\Users{YOUR USERNAME}\AppData\Roaming\npm
solve it for me

I found that I can use npm version 9.0.0 but I had to uninstall gulp-sass and then reinstall it. All was fine after that

On Ubuntu, if you've installed your own copy of node you'll need to clean everything up. So remove node and npm. Then get rid of the node_modules directory... in my case

    sudo rm -rf /usr/local/lib/node_modules

For others use find or locate to discover where your node_modules directories may be:

    sudo find / -name "node_modules" --print 2>/dev/null

I also removed my .npm directory in my home dir: rm -rf ~/.npm.

Note, it may be suitable to just remove the npm subdirectories from node_modules directories above, but I did not test this. I just went for clean then I reinstalled the same version of node that was giving me the problems. In my case that was 8.9.4LTS, with the normal make install.

I started to have this issue after another upgrade of Node (from 8.5.6 to 8.10.0 in my case) with n. Following fixed it for me (needs yarn to be installed):

rm -rf /usr/local/lib/node_modules/npm
yarn global add [email protected] #put your desired version of npm here

on windows 7, i fixed the problem by going to
C:\Users\my.username\AppData\Roamingnpm and deleting the node_modules folder. afterwards i could run "npm install" without problems.

using

node v9.8.0
npm v3.5.3

Hello, why don't you try:

rm -rf node_modules
npm install

On OSX High Sierra / Brew Installed, similar to @artemv and others:

brew uninstall nodejs
sudo rm -rdf cd /usr/local/lib/node_modules/
brew install nodejs

maybe you have multiple versions graceful-fs

  1. npm list graceful-fs
  2. rm invalid's graceful-fs
  3. npm install

I was running into this too with Ionic, and tried all of the remedies above and nothing worked. Then, just to see what would happen, I ran yarn and it fixed it all up for me (I already had it installed for something else)

Ionic CLI 2.2.1
Node 8.9.4
Yarn 1.5.1
Win 10

Ve a tu carperta node_modules
C:\Program Filesnodejsnode_modules.
Elimina la carpeta npm, con todo su contendió, instala la versión que desees.

I had the same issue. I was using node 8.11.0. Now I have downgraded it to 6.0.0 and it will work. Thanks for your valuable suggestions

For my Mac, I had to remove node/npm/npm settings/reinstall node LTS/Cordova -- only 1 sudo command should be required.

remove node and global node_modules

sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}

remove npm user settings from your profile

rm -rf ~/.npm
rm -rf ~/.npm-global
rm -rf ~/.npmrc
nano ~/.profile      <-- remove any path additions regarding NPM and save

install NVM

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

install Node LTS with NVM

nvm install --lts

update ionic project by removing any previous node_modules, reinstall ionic/cordova

cd {project path}
rm -rf node_modules
npm install -g ionic cordova

finally, add iOS platform works...

cordova platform add ios

All of this setup my Mac with the following versions:

cli packages: (/Users/{xxxxxx}/.nvm/versions/node/v8.11.2/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.3.0

System:

    Node  : v8.11.2
    npm   : 5.6.0 
    OS    : macOS High Sierra
    Xcode : Xcode 9.3.1 Build version 9E501 

Environment Variables:

    ANDROID_HOME : not set

I had the same issue with Node 10.3.0 (Windows 10). I followed the instructions for handling a similar error here and it fixed both errors. The command was: npm install --save-dev grunt-google-cdn

Had this issue using Win 10 Wsl, node v. 9.3.0, npm v. 6.1.0 & gulp 3.9 and what helped using gulp again was npm audit fix

Using n for version management. What fixed it for me:

curl -0 -L https://npmjs.com/install.sh | sudo sh
sudo npm cache clean

@aromot where can i find \global_modulesnode_modules ?

@QuocCong after removing i /c/Users/JoSuper/AppData/Roaming/npm/ get this

$ cordova platform add android@6
bash: /c/Users/JoSuper/AppData/Roaming/npm/cordova: No such file or directory

@josuper The "global_modules" folder is located at the root of your NodeJS installation. I can't tell where it is exactly, I'm using a custom folder instead of the default path proposed by the installation.

Downgrading the node version worked for me. I used volta-cli to try a few different node versions until I found one that works.

C:xampp\htdocs\DICA\dica-upload-ok-calendario-ko>npm run dev

[email protected] dev C:xampp\htdocs\DICA\dica-upload-ok-calendario-ko
npm run development

internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module 'internal/util/types'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at evalmachine.:44:31
at Object. (C:xampp\htdocs\DICA\dica-upload-ok-calendario-konode_modulesnpmnode_modules\graceful-fs\fs.js:11:8)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: npm run development
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Utilizador\AppData\Roamingnpm-cache_logs\2019-10-14T16_25_58_379Z-debug.log

C:xampp\htdocs\DICA\dica-upload-ok-calendario-ko>yarn install
'yarn' is not recognized as an internal or external command,
operable program or batch file.

Can someone help me?

Upgrading the node version to the stable one worked for me.
npm cache clean -f
npm install n stable -g
npm cache clean -f

I know it's closed but i want to add a alternative solution for this problem.

Yes, node version update works every time. Because it's related with npm package version. Real problem is npm version to old for this. You can update npm version with node version. For example: nodejs.org download page said that: "Latest LTS Version: 12.14.1 (includes npm 6.13.4)". If you uninstall npm in your global and after that install again, you will fix this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mohammad-Quanit picture Mohammad-Quanit  ·  5Comments

robboerman picture robboerman  ·  3Comments

endquote picture endquote  ·  4Comments

jonerer picture jonerer  ·  4Comments

hkeio picture hkeio  ·  3Comments