module.js:340
throw err;
^
Error: Cannot find module 'inherits'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/lib/node_modules/npmconf/npmconf.js:3:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
asked Nov 12, 2013 at 15:23
The following worked for me. The other answer, sudo yum install nodejs-inherits*, did not do the trick for me. Note, before running the following, you may want to back up your /usr/lib/node_modules folder so you can refer back to it to recall what all you had installed globally.
sudo yum erase nodejs npm
sudo rm -rf /usr/lib/node_modules
sudo yum install nodejs npm
Hope this helps someone.
answered Dec 25, 2013 at 23:58
user1978317user1978317
3432 silver badges6 bronze badges
0
I just uninstalled and reinstalled npm:
brew uninstall npm
brew install npm
It didn’t go without issue, I also had to reclaim the ownership of some libraries:
sudo chown -R nice /usr/local/lib/node_modules/
and then
brew postinstall npm
Nithin
3,6413 gold badges29 silver badges55 bronze badges
answered Mar 1, 2016 at 13:57
NicoNico
3,9681 gold badge19 silver badges19 bronze badges
0
To share my info, I faced this issue, and I solved it by installing inherits
as the following:
sudo npm install inherits
This the github repo of it.
answered Oct 9, 2015 at 16:26
sudo yum install nodejs-inherits* didn’t work for me.
Also I didn’t want to erase node_modules.
Erasing inherit modules and installing/reinstalling only the new one worked:
sudo yum erase nodejs-inherits
sudo yum erase nodejs-inherits1
sudo yum install nodejs-inherits
answered Nov 22, 2014 at 13:21
After exhausting other possibilities (re-installing npm and various other nodejs packages), I finally tried the simple one.
sudo yum install nodejs-inherits*
That worked for me.
answered Nov 12, 2013 at 15:23
hourbackhourback
1,1094 gold badges12 silver badges26 bronze badges
1
I had this issue on Windows recently, updating npm fixed it for me.
npm update npm -g
answered Apr 12, 2015 at 22:12
SavoryBytesSavoryBytes
35k4 gold badges51 silver badges61 bronze badges
It happend when I switch my node to version 5.5.0 by ‘n’.
then I switch back to node 0.10.22,which I used befor, and run
npm update npm -g
then it is fine now
answered Jan 27, 2016 at 11:55
I faced the same error in Windows 7 32 bit system and fixed it by uninstalling the nodejs itself. After freshly installing the nodejs, I ran the following commands
npm install -g npm-windows-upgrade
npm-windows-upgrade -p -v latest
This has fixed the issue for me
answered Sep 14, 2017 at 9:44
NigilanNigilan
7461 gold badge6 silver badges18 bronze badges
Running npm install –y
helps me in my situation.
I don’t know what -y
option means.
Nathan Tuggy
2,23527 gold badges30 silver badges38 bronze badges
answered Nov 1, 2016 at 5:42
Phuc ThaiPhuc Thai
7087 silver badges17 bronze badges
Ok i found a solution on my own
sam@Sams-MacBook ~/xxx/xxxxxx $ **brew link node**
Error: Operation already in progress for node
Another active Homebrew process is already using node.
Please wait for it to finish or terminate it to continue.
sam@Sams-MacBook ~/xxx/xxxxxx $ **brew update**
==> Migrating Homebrew to v0.9.9
remote: Counting objects: 296, done.
remote: Compressing objects: 100% (238/238), done.
remote: Total 296 (delta 154), reused 138 (delta 44), pack-reused 0
Receiving objects: 100% (296/296), 460.59 KiB | 0 bytes/s, done.
Resolving deltas: 100% (154/154), completed with 152 local objects.
From https://github.com/Homebrew/brew
+ dde20cd...cab97cf master -> origin/master (forced update)
HEAD is now at cab97cf Revert "keg_relocate: Exclude hardlinks from mach_o_files."
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
https://git.io/brew-analytics
==> Txxxing homebrew/core
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 3711, done.
remote: Compressing objects: 100% (3595/3595), done.
remote: Total 3711 (delta 14), reused 2204 (delta 6), pack-reused 0
Receiving objects: 100% (3711/3711), 2.87 MiB | 1.19 MiB/s, done.
Resolving deltas: 100% (14/14), done.
Checking connectivity... done.
Txxxed 3588 formulae (3,737 files, 8.9M)
==> Cleaning up /Library/Caches/Homebrew...
Removing: /Library/Caches/Homebrew/imagemagick-6.9.3-6.yosemite.bottle.tar.gz... (7M)
Removing: /Library/Caches/Homebrew/libpng-1.6.21.yosemite.bottle.tar.gz... (426.5K)
Removing: /Library/Caches/Homebrew/libtiff-4.0.6.yosemite.bottle.tar.gz... (1M)
Removing: /Library/Caches/Homebrew/mysql-5.7.11.yosemite.bottle.tar.gz... (92.1M)
Removing: /Library/Caches/Homebrew/node-5.9.0.tar.xz... (12.6M)
Removing: /Library/Caches/Homebrew/node-5.9.0.yosemite.bottle.tar.gz... (10.0M)
Removing: /Library/Caches/Homebrew/unixodbc-2.3.2_1.yosemite.bottle.1.tar.gz... (321.7K)
==> Migrating /Library/Caches/Homebrew to /Users/sam/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Already up-to-date.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
==> Caveats
Please note by default only English locale support is provided. If you need
full locale support you should either rebuild with full icu:
`brew reinstall node --with-full-icu`
or add full icu data at runtime following:
https://github.com/nodejs/node/wiki/Intl#using-and-customizing-the-small-icu-build
sam@Sams-MacBook ~/xxx/xxxxxx $ **sudo chown -R $USER /usr/local**
sam@Sams-MacBook ~/xxx/xxxxxx $ **brew link --overwrite node**
sam@Sams-MacBook ~/xxx/xxxxxx $ **brew install node**
Warning: node-6.2.2 already installed
sam@Sams-MacBook ~/xxx/xxxxxx $ **which npm**
/usr/local/bin/npm
sam@Sams-MacBook ~/xxx/xxxxxx $ **brew postinstall node**
sam@Sams-MacBook ~/xxx/xxxxxx $ **npm -v**
3.9.5
I try to reinstall node with brew again and get the message my node was ot linked.. so i try to solve this problem.
Содержание
- Cannot find module ‘inherits’ #1404
- Comments
- Installing Ionic error: Cannot find module ‘inherits’ #1378
- Comments
- How to solve «Error: Cannot find module ‘*.js’» with Node.js
- Introduction
- How to fix «Error: Cannot find module»
- General tips
- How to change directories
- How to see what directory you are in
- How to print the contents of current directory
- Conclusion
- Error: Cannot find module ‘ansi’ #10
- Comments
- Error: Cannot find module ‘semver’ #9445
- Comments
Cannot find module ‘inherits’ #1404
Error: Cannot find module ‘inherits’
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object. (C:UserskimliAppDataRoamingnpmnode_modulesionicnode_modulesglobglob.js:42:14)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
The text was updated successfully, but these errors were encountered:
Could you provide me with the output from ionic info from within your project directory? Thanks, this should help in troubleshooting.
I just had this issue when trying to start a new v2 project. Fixed it with:
This is my output I’m trying to update since I was still on Angular2 RC 4
That is interesting @btsiders ‘s solution seems to work for me as well.
Was not expecting so!
I’m having the same problem but with module ‘extend’.
I tried @btsiders ‘s solution but it did not work
- ionic info:
Caught exception:
Error: Cannot find module ‘extend’
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/usr/local/lib/node_modules/ionic/node_modules/request/index.js:17:29)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
having the same problem, same error.
tried uninstall/install cordova and ionic -g, nothing helps. can’t do ionic info
stuck with the first project.
$ node —version
v6.10.1
$ nvm —version
0.33.1
$ cordova —version
6.5.0
$ uname -v
Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3
Источник
Installing Ionic error: Cannot find module ‘inherits’ #1378
Hi, I’ve just been trying to install Ionic 2 (as I was originally trying to update to the latest beta). Now I keep getting this error:
Caught exception: Error: Cannot find module ‘inherits’ at Function.Module._resolveFilename (module.js:455:15) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at Object. (/usr/local/lib/node_modules/ionic/node_modules/glob/glob.js:42:14) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3)
I’ve tried option 1 of the how to fix npm permissions problems from the npm site (https://docs.npmjs.com/getting-started/fixing-npm-permissions). But still the error keeps on happening.
The text was updated successfully, but these errors were encountered:
Hello, thanks for opening an issue with us! Would you mind posting the command you used to try to install the cli? Thanks!
I used npm install -g ionic I also tried with sudo
This could help:
npm uninstall -g ionic cordova
npm install -g ionic cordova
I actually found out what the problem was, I have a newer version of Node running, not the LTS version. So I had to remove Node and npm, then install nvm to have both the LTS version and a latest version (which I need for a workshop I’m attending).
So now everything is working (as long as I remember which version I’m running on).
Источник
How to solve «Error: Cannot find module ‘*.js’» with Node.js
Introduction
If you are trying to run your Node.js application and you get something like this:
then you are most likely trying to run the wrong file. It is possible you are missing a dependency that is needed from npm install , but if it says it cannot find the main file you are trying to run, then you are trying to run a file that does not exist. It is a common mistake.
How to fix «Error: Cannot find module»
You need to double check you are running the correct file from the correct directory. Here are some steps to diagnose.
General tips
Here are some general things to keep in mind when diagnosing the issue:
- Make sure you are in the correct directory.
- Make sure you are trying to run the correct file name.
- File and directory names are case sensitive.
How to change directories
To change directories, use the cd command in your terminal. For example, if your username was Me on the computer:
How to see what directory you are in
To check what directory you are currently in, use the folowing in your terminal.
How to print the contents of current directory
To see what files and directories exist in your current directory use the following in your terminal:
Conclusion
After reading this you should have some idea why you get the error Error: Cannot find module and how to diagnose and fix the problem.
Источник
Error: Cannot find module ‘ansi’ #10
- Extension Version: 0.1.11
- VS Code Version: 1.5.3
- OS Version: Ubuntu 16.04
- Node.js Version (result of command node -v ): 4.2.6
- NPM Version (result of command npm -v ): 3.5.2
Steps to Reproduce:
- Select pick colour in Sass file
- No previews and crash when picker chosen.
Log:
(Click menu of VS Code «Help > Toggle Developer Tools», and click «Console» tab)
The text was updated successfully, but these errors were encountered:
Hi @wjdp, thank you for the report.
It seems that loading ansi module the NPM requires failed.
Does your NPM work fine?
Please check that the module was installed into /usr/share/npm/node_modules/ansi .
It’s not there. NPM seems to be working fine. I’ve tried to manually install which has not helped:
Still get the same result in vscode
The npmlog module that is a part of NPM depends on the ansi .
Then, the ansi should exist in /usr/share/npm/node_modules/npmlog/node_modules/ansi .
If that is not there, try:
BTW, does the issue happen in only SASS files?
No, any time I try to call any commands this project has added to the command palette. The preview of hex colours does not happen anywhere.
However after restarting vscode I’m still getting:
[processBridge]: Error: Cannot find module ‘ansi’
Источник
Error: Cannot find module ‘semver’ #9445
Today I encountered this and not able to install a single package .
The text was updated successfully, but these errors were encountered:
Hi, I’ve encountered almost the same issue. any solutions?
angular-seed@0.0.0 prestart c:Sitestemplatestore
npm install
module.js:338
throw err;
^
Error: Cannot find module ‘semver’
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (C:UserssteinAppDataRoamingnpmnode_modulesnpmlibconfigdefaults.js:7:14)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
npm ERR! Windows_NT 10.0.10240
npm ERR! argv «c:Program Filesnodejsnode.exe» «c:Program Filesnodejsnode_modulesnpmbinnpm-cli.js» «start»
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! angular-seed@0.0.0 prestart: npm install
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-seed@0.0.0 prestart script ‘npm install’.
npm ERR! This is most likely a problem with the angular-seed package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm install
npm ERR! You can get their info via:
npm ERR! npm owner ls angular-seed
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:Sitestemplatestorenpm-debug.log
I just restarted my PC and the error vanished. However, the issue is why it occurs in the first place .
Gonna try right now, pc has restarted. Anything else you did when the error vanished? Remade the entire directory with npm install first?
I’m on Windows 10
Just reinstall npm , i think you should be good to go !
You mean ‘npm install’ again to the directory where I’ve cloned the app (angular seed) to? No luck 🙁 I’ll try again tomorrow morning
Enviado desde mi iPhone
Just reinstall npm , i think you should be good to go !
—
Reply to this email directly or view it on GitHub.
I’m running Linux Arch. Semver was a separate package that was not reinstalled when I tried reinstalling npm. When I realized this I just reinstalled semver and this issue was resolved in my case.
1 cd ghost
2 rm -rf node_modules
3 npm install —production
4 npm start
I am encountering this with windows10, and when I tried reinstalling node, doesn’t work.
——- what I get
module.js:471
throw err;
^
Error: Cannot find module ‘semver’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (C:UsersPzhAppDataRoamingnpmnode_modulesnpmlibutilsunsupported.js:2:14)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
@imPZH could you try installing the Semver package like techwooten did here: #9445 (comment) ?
npm install -g semver
@Charlotteis I tried. once I type ‘npm’,
such as
‘npm’
‘npm -v’
‘npm install -g semver ‘
I got the error.
I deleted ‘npm’ and ‘npm_cache’ folder in ‘ C:UsersPzhAppDataRoaming’, and changed environment variables ‘PATH’. The error disappears.
Any still having this issue after trying what @imPZH suggested?
Similar error happens on simple npm command call. Take a look at this Docker image log:
https://hub.docker.com/r/jazzypro/ubuntu-node-electron/builds/bky5uoiqd4wsfkqkwphvgov/
This error means the npm installation itself is hosed. Remove npm from your local machine and reinstall it. Assuming you don’t have any weird filesystem problems going on with files going suddenly missing.
@saru95 seems to have resolved their issue, so I’m going to close this one.
Источник
Запуск «npm» возвращает «Ошибка: не удается найти модуль« наследует »»
module.js:340
throw err;
^
Error: Cannot find module 'inherits'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/lib/node_modules/npmconf/npmconf.js:3:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
9 ответы
Следующее сработало для меня. Другой ответ, sudo yum install nodejs-inherits*, мне не помог. Обратите внимание: перед запуском следующего вы можете сделать резервную копию папки /usr/lib/node_modules, чтобы вы могли вернуться к ней, чтобы вспомнить, что вы установили глобально.
sudo yum erase nodejs npm
sudo rm -rf /usr/lib/node_modules
sudo yum install nodejs npm
Надеюсь, это поможет кому-то.
ответ дан 05 апр.
Я только что удалил и переустановил npm:
brew uninstall npm
brew install npm
Это не обошлось без проблем, мне также пришлось вернуть права собственности на некоторые библиотеки:
sudo chown -R nice /usr/local/lib/node_modules/
, а затем
brew postinstall npm
ответ дан 15 апр.
Чтобы поделиться своей информацией, я столкнулся с этой проблемой и решил ее, установив inherits
в дальнейшем:
sudo npm install inherits
Это гитхаб РЕПО из него.
ответ дан 09 окт ’15, 17:10
sudo yum install nodejs-inherits* у меня не сработал. Также я не хотел стирать node_modules.
Стирание наследуемых модулей и установка/переустановка только нового сработали:
sudo yum erase nodejs-inherits
sudo yum erase nodejs-inherits1
sudo yum install nodejs-inherits
Создан 22 ноя.
Исчерпав другие возможности (переустановив npm и различные другие пакеты nodejs), я, наконец, попробовал простой.
sudo yum install nodejs-inherits*
Это сработало для меня.
Создан 12 ноя.
Недавно у меня была эта проблема в Windows, обновление npm исправило ее для меня.
npm update npm -g
ответ дан 12 апр.
Это произошло, когда я переключил свой узел на версию 5.5.0 на «n».
затем я переключаюсь обратно на узел 0.10.22, который я использовал до этого, и запускаю
npm update npm -g
то сейчас нормально
Создан 27 янв.
Я столкнулся с той же ошибкой в 7-битной системе Windows 32 и исправил ее, удалив сам nodejs. После новой установки nodejs я выполнил следующие команды
npm install -g npm-windows-upgrade
npm-windows-upgrade -p -v latest
Это решило проблему для меня
Создан 14 сен.
Бег npm install –y
помогает мне в моей ситуации.
Я не знаю, что -y
вариант значит.
Создан 01 ноя.
Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками
node.js
npm
redhat
yum
or задайте свой вопрос.
Description of problem: The symbolic link for /usr/lib/node_modules/inherits becomes mangled upon upgrade to 1.3.3 Version-Release number of selected component (if applicable): 1.3.3 How reproducible: Have not tried (Numerous reports from RHEL/CentOS/Fedora users) Steps to Reproduce: 1. Install pre npm 1.3.3 2. Update to npm 1.3.3 3. Execute npm with any parameters Actual results: npm ERR! Error: Cannot find module 'inherits' (See link below for full output) Expected results: npm to operate as expected Additional info: https://github.com/isaacs/npm/issues/3724 Workaround: Erase the npm package and reinstall
Just wanted to add the following context: https://github.com/isaacs/npm/issues/3724#issuecomment-22784969 For the workaround, we tried to simply uninstall the yum packages and reinstall. It didn't fix the problem with the symlinks. Instead, our system admin had to perform the full: yum erase npm nodejs rm -rf /usr/lib/node_modules yum install npm
Looks like there's an rpm bug somewhere, since the package is correct since it installs cleanly fine. Not sure why rpm isn't updating some symlinks. :-( This is easily "fixed" by upgrading npm; newer versions don't require inherits anymore. But stuff down the stack does, and in case the symlinks are messed up there too I added a post-install script to nodejs-inherits that fixes up the symlinks when upgrading from older versions. Sorry for the trouble. Fixed builds will be queued for epel-testing shortly.
npm-1.3.6-4.el6, node-gyp-0.10.6-2.el6, nodejs-assert-plus-0.1.4-1.el6, nodejs-bindings-1.1.1-1.el6, nodejs-block-stream-0.0.7-1.el6, nodejs-cryptiles-0.2.2-1.el6, nodejs-form-data-0.1.0-1.el6, nodejs-fstream-0.1.24-1.el6, nodejs-glob-3.2.6-1.el6, nodejs-hawk-1.0.0-1.el6, nodejs-mime-1.2.10-1.el6, nodejs-mute-stream-0.0.4-1.el6, nodejs-nopt-2.1.2-1.el6, nodejs-normalize-package-data-0.2.1-1.el6, nodejs-npmconf-0.1.2-1.el6, nodejs-npm-registry-client-0.2.27-2.el6, nodejs-read-1.0.5-1.el6, nodejs-read-installed-0.2.3-1.el6, nodejs-read-package-json-1.1.1-1.el6, nodejs-request-2.25.0-1.el6, nodejs-rimraf-2.2.2-1.el6, nodejs-semver-2.1.0-1.el6, nodejs-sha-1.2.1-1.el6, nodejs-tar-0.1.18-1.el6, nodejs-inherits-2.0.0-4.el6 has been submitted as an update for Fedora EPEL 6. https://admin.fedoraproject.org/updates/FEDORA-EPEL-2013-11191/node-gyp-0.10.6-2.el6,nodejs-assert-plus-0.1.4-1.el6,nodejs-bindings-1.1.1-1.el6,nodejs-block-stream-0.0.7-1.el6,nodejs-cryptiles-0.2.2-1.el6,nodejs-form-data-0.1.0-1.el6,nodejs-fstream-0.1.24-1.el6,nodejs-glob-3.2.6-1.el6,nodejs-hawk-1.0.0-1.el6,nodejs-mime-1.2.10-1.el6,nodejs-mute-stream-0.0.4-1.el6,nodejs-nopt-2.1.2-1.el6,nodejs-normalize-package-data-0.2.1-1.el6,nodejs-npmconf-0.1.2-1.el6,nodejs-npm-registry-client-0.2.27-2.el6,nodejs-read-1.0.5-1.el6,nodejs-read-installed-0.2.3-1.el6,nodejs-read-package-json-1.1.1-1.el6,nodejs-request-2.25.0-1.el6,nodejs-rimraf-2.2.2-1.el6,nodejs-semver-2.1.0-1.el6,nodejs-sha-1.2.1-1.el6,nodejs-tar-0.1.18-1.el6,nodejs-inherits-2.0.0-4.el6,npm-1.3.6-4.el6
Thanks for the quick turnaround!
Package npm-1.3.6-4.el6, node-gyp-0.10.6-2.el6, nodejs-assert-plus-0.1.4-1.el6, nodejs-bindings-1.1.1-1.el6, nodejs-block-stream-0.0.7-1.el6, nodejs-cryptiles-0.2.2-1.el6, nodejs-form-data-0.1.0-1.el6, nodejs-fstream-0.1.24-1.el6, nodejs-glob-3.2.6-1.el6, nodejs-hawk-1.0.0-1.el6, nodejs-mime-1.2.10-1.el6, nodejs-mute-stream-0.0.4-1.el6, nodejs-nopt-2.1.2-1.el6, nodejs-normalize-package-data-0.2.1-1.el6, nodejs-npmconf-0.1.2-1.el6, nodejs-npm-registry-client-0.2.27-2.el6, nodejs-read-1.0.5-1.el6, nodejs-read-installed-0.2.3-1.el6, nodejs-read-package-json-1.1.1-1.el6, nodejs-request-2.25.0-1.el6, nodejs-rimraf-2.2.2-1.el6, nodejs-semver-2.1.0-1.el6, nodejs-sha-1.2.1-1.el6, nodejs-tar-0.1.18-1.el6, nodejs-inherits-2.0.0-4.el6: * should fix your issue, * was pushed to the Fedora EPEL 6 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=epel-testing npm-1.3.6-4.el6 node-gyp-0.10.6-2.el6 nodejs-assert-plus-0.1.4-1.el6 nodejs-bindings-1.1.1-1.el6 nodejs-block-stream-0.0.7-1.el6 nodejs-cryptiles-0.2.2-1.el6 nodejs-form-data-0.1.0-1.el6 nodejs-fstream-0.1.24-1.el6 nodejs-glob-3.2.6-1.el6 nodejs-hawk-1.0.0-1.el6 nodejs-mime-1.2.10-1.el6 nodejs-mute-stream-0.0.4-1.el6 nodejs-nopt-2.1.2-1.el6 nodejs-normalize-package-data-0.2.1-1.el6 nodejs-npmconf-0.1.2-1.el6 nodejs-npm-registry-client-0.2.27-2.el6 nodejs-read-1.0.5-1.el6 nodejs-read-installed-0.2.3-1.el6 nodejs-read-package-json-1.1.1-1.el6 nodejs-request-2.25.0-1.el6 nodejs-rimraf-2.2.2-1.el6 nodejs-semver-2.1.0-1.el6 nodejs-sha-1.2.1-1.el6 nodejs-tar-0.1.18-1.el6 nodejs-inherits-2.0.0-4.el6' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-EPEL-2013-11191/node-gyp-0.10.6-2.el6,nodejs-assert-plus-0.1.4-1.el6,nodejs-bindings-1.1.1-1.el6,nodejs-block-stream-0.0.7-1.el6,nodejs-cryptiles-0.2.2-1.el6,nodejs-form-data-0.1.0-1.el6,nodejs-fstream-0.1.24-1.el6,nodejs-glob-3.2.6-1.el6,nodejs-hawk-1.0.0-1.el6,nodejs-mime-1.2.10-1.el6,nodejs-mute-stream-0.0.4-1.el6,nodejs-nopt-2.1.2-1.el6,nodejs-normalize-package-data-0.2.1-1.el6,nodejs-npmconf-0.1.2-1.el6,nodejs-npm-registry-client-0.2.27-2.el6,nodejs-read-1.0.5-1.el6,nodejs-read-installed-0.2.3-1.el6,nodejs-read-package-json-1.1.1-1.el6,nodejs-request-2.25.0-1.el6,nodejs-rimraf-2.2.2-1.el6,nodejs-semver-2.1.0-1.el6,nodejs-sha-1.2.1-1.el6,nodejs-tar-0.1.18-1.el6,nodejs-inherits-2.0.0-4.el6,npm-1.3.6-4.el6 then log in and leave karma (feedback).
nodejs-inherits-2.0.0-4.fc19 has been pushed to the Fedora 19 stable repository. If problems still persist, please make note of it in this bug report.
nodejs-inherits-2.0.0-4.fc18 has been pushed to the Fedora 18 stable repository. If problems still persist, please make note of it in this bug report.
nodejs-request-2.25.0-3.el6, npm-1.3.6-4.el6, node-gyp-0.10.6-2.el6, nodejs-assert-plus-0.1.4-1.el6, nodejs-bindings-1.1.1-1.el6, nodejs-block-stream-0.0.7-1.el6, nodejs-cryptiles-0.2.2-1.el6, nodejs-fstream-0.1.24-1.el6, nodejs-glob-3.2.6-1.el6, nodejs-hawk-1.0.0-1.el6, nodejs-mute-stream-0.0.4-1.el6, nodejs-nopt-2.1.2-1.el6, nodejs-normalize-package-data-0.2.1-1.el6, nodejs-npmconf-0.1.2-1.el6, nodejs-read-1.0.5-1.el6, nodejs-rimraf-2.2.2-1.el6, nodejs-semver-2.1.0-1.el6, nodejs-sha-1.2.1-1.el6, nodejs-tar-0.1.18-1.el6, nodejs-inherits-2.0.0-4.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report. |
If you’re a developer that works with Node JS and JavaScript libraries and frameworks like React, Vue, and Angular, then you might have encountered the «Error: cannot find module» error.
In this article, I’m going to show you how to fix the error.
Why the «Error: cannot find module» Occurs
This error occurs because of the following reasons:
- you’re trying to import an item from a module you don’t have installed in your project directory
- you’re importing some things from an outdated package
- you’re pointing to a file that does not exist
In the screenshot below, you can see that I’m getting the error:
I’m getting the error because I’m trying to import the freeCodeCamp icon from the react-icons package, which I don’t have installed.
import { FaFreeCodeCamp } from "react-icons/fa";
How to Fix the «cannot find module» Error
If you get this error, the solution is always in the error. The module (package) not found is always specified in the format «Module not found: Error: Can’t resolve ‘package name’ in ‘project directory».
In my case, I got it like this «Module not found: Error: Can’t resolve ‘react-icons/fa’ in ‘C:UsersuserDesktopProjectsAddress Locatoraddress-locatorsrc'».
To fix the error, you need to install the package that is absent in your project directory – npm install package-name
or yarn add package-name
.
In my case, I need to install the react-icons
package so the freeCodeCamp icon can be resolved. I’ll do that by running yarn add react-icons
.
Once I install the package and run the app, everything should successfully compile:
If you install the package but you still get the error, then follow the steps below:
- delete the node modules folder by running
rm -rf node_modules
- delete package.lock.json file by running
rm -f package-lock.json
- clean up the NPM cache by running
npm cache clean --force
- install all packages again by running
npm install
That should fix the error for you.
Conclusion
When you get the “cannot find module” error, or “module not found”, it means you’ve not installed the package you’re trying to use.
If the error occurs even if you have the package installed, then the fixes suggested in this article can help you out.
Thank you for reading.
Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started
When you are working in Node, you will sometimes encounter the error Cannot find module 'module-name'
with the error code MODULE_NOT_FOUND
.
The error looks like this:
internal/modules/cjs/loader.js:796
throw err;
^
Error: Cannot find module 'module'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
In this post, we’ll learn how to resolve this error.
What is the problem?
The issue is that Node is unable to find the module that you are trying to import into your Node application.
The most common reason for this is that you simply haven’t installed the project’s dependencies yet.
The project’s dependencies are listed in the package.json
file at the root of the project.
The Solution
To fix the Cannot find module
error, simply install the missing modules using npm
.
To so, you can use the following command:
npm install
If you are using the yarn
package manager, you can use the following command:
yarn install
This will install the project’s dependencies into your project so that you can use them.
Sometimes, this might still not resolve it for you. In this case, you’ll want to just delete your node_modules
folder and lock file (package-lock.json
or yarn.lock
) and try again.
This is how you can delete the node_modules
folder and lock files:
rm -rf node_modules
rm package-lock.json
rm yarn.lock
Local files
If your module is not coming from a remote source, you are seeing the error because the path to the local file is not correct.
Try to confirm that the path pointing to the local module is correct and your error should be resolved.
Conclusion
The Cannot find module
error is a common error that usually happens when dependencies are not installed. Once you install your dependencies and ensure that the paths are correct, you can resolve the error and run your application successfully.
Hopefully, this resolved the issue for you.
Thanks for reading!
If you want to learn about web development, founding a start-up, bootstrapping a SaaS, and more, follow me on Twitter! You can also join the conversation over at our official Discord!
-
Support Us
-
Join
-
Share
-
Tweet
-
Share
Give feedback on this page!