I am getting the following exception whenever I type heroku
module.js:544
throw err;
^
Error: Cannot find module './node.js'
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 Object.<anonymous> (C:\Users\aksha\AppData\Local\heroku\client\node_modules\debug\src\index.js:9:20)
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)
at Function.Module._load (module.js:495:3)
I tried to reinstall the CLI but I still get the same error.
Update
I have this problem on Windows. Haven't tested it on other OS.
I often but intermittently get this same error. It's really frustrating because it seems to happen out of nowhere on the same commands I have previous issued with great success. The only work around I've found is the brew uninstall --force heroku and then re-brew install heroku. π
Please halp.
https://gist.github.com/veganstraightedge/8b2d5665bc1c915515cc9daf3328a7a9
I noticed this could happen on updates because if the previous CLI was older than 24 hours it would delete the old CLI. I made this 7 days instead and more importantly made it touch the current CLI on every run to prevent it from deleting right after it updates.
Though, even though that threw an exception, it wasn't major as the update still succeeded and it shouldn't break anything else. So I don't think that was happening here.
Looking at both of your tracebacks, I see it referencing js files inside of ~/.local/share/heroku/client/*.js. We don't actually put anything directly in that directory but now scope it to each version like ~/.local/share/heroku/client/v1.2.3/*. This means there is old code somewhere that is causing problems.
We had a really complicated issue earlier this month when we put this change in that especially impacted homebrew users. It's hard to explain, but it resulted in a situation where the updater would have to run 3 times before it finally was able to move to this new path without issue.
Everything should be fixed now, and even if you've seen this happen a couple of times it should no longer happen again.
I'm a little confused how reinstalling with brew would've fixed anything. Our homebrew formula just maps to the current autoupdated CLI inside of ~/.local/share/heroku* and homebrew doesn't offer a hook for us to clean out that directory when you remove the formula.
Though now that I think of it, I may look into clearing the autoupdated CLI when we install the formula.
homebrew is doing some kind of sandboxing and even by shelling out to rm -rf I can't seem to delete that directory in the formula.
I'm not sure exactly how, but I think when you were reinstalling with brew it might have worked for a while but then did some updating logic that put you on the broken release from a few weeks ago that had this issue. If you delete ~/.local/share/heroku/client it should not happen again.
And of course make sure your brew formulas are updated. Current cli version is 6.15.20.
What's the over/under that this is gonna get fixed? I have to uninstall / reinstall several times per week.
Weβre not getting any other reports of it so I assume itβs been fixed. Have you tried deleting the client directory? Also it would be good to fully purge the homebrew install by deleting the Cellar directory
@jdxcode Ok. I un/re-installed again. If I don't get any of these errors this week, I'll consider resolved (for me, at least). Thanks!
Yep. working now. closing the issue.
It happened again.
> heroku addons
module.js:557
throw err;
^
Error: Cannot find module '@cli-engine/engine'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/s/.local/share/heroku/client/bin/heroku.js:2:15)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
@veganstraightedge would you mind telling me what files are in /Users/s/.local/share/heroku/client? Also, is there anything you can think of that might be screwing with the last modified time of files or the clock? We clean out old CLIs after a week when we autoupdate the CLI. This shouldn't happen for other reasons, but I feel there might be something going on where the CLI thinks it's out of date but it isn't.
Also, can you send me ~/Library/Caches/heroku/autoupdate.log and ~/Library/Caches/heroku/error.log?
I still haven't seen any reports of this happening. The issue from before we had an incident about and affected many people, but it's certainly fixed now so it must be something else (but probably in the same area of the code).
Lastly, if you just want it to work, you could install the CLI with npm install -g heroku-cli. That version will never autoupdate.
@jdxcode Here's a gist of those two files.
https://gist.github.com/veganstraightedge/e0f43dcf12cb7f2b2e5c4ff6cff8b3dc
I don't know of anything that would be mucking with time or the clock.
sorry for the delay here @veganstraightedge, I just got back from vacation. Working through our support tickets at the moment but hope to be able to investigate further soon.
Thanks @jdxcode!
For context, I _just_ tested it again and got this error.
> heroku info -r heroku
module.js:557
throw err;
^
Error: Cannot find module '@cli-engine/engine'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/s/.local/share/heroku/client/bin/heroku.js:2:15)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
ok so we don't use ~/.local/share/heroku/client/bin/heroku.js anymore for sure. The fact you have that file at all is telling me you have some old code somewhere on your machine that is getting run and almost certainly causing things to go awry. But what and where I'm not sure.
Do you have the directory /usr/heroku? If so, delete that entirely.
Since this is only happening to you (still haven't received another report since January), using the npm version of the CLI would also fix this.
Also, do you have the heroku ruby gem installed? I doubt this would cause the problem, but worth checking.
Also, what is the output of which heroku?
> cd /usr/heroku
-bash: cd: /usr/heroku: No such file or directory
> which heroku
/usr/local/bin/heroku
> gem list heroku
*** LOCAL GEMS ***
The way that I uninstall / re-install when it breaks is:
brew uninstall --force heroku && brew install heroku
can you delete /Users/s/.local/share/heroku/client/bin/heroku.js if it exists? does that break your CLI?
Deleted. Does not break CLI.
Do me a favor and delete ~/Library/Caches/heroku. Just keep using the CLI. If it breaks again, send me those 2 files again. Also, delete ~/.heroku if it exists (it shouldn't, this is an old directory) and let me know if that re-creates itself. From what it looks like, you are definitely on the most recent version of the CLI and should not experience an issue. If something goes wrong and that heroku.js file reappears, an old version is getting installed again for some reason.
rm -rfed ~/Library/Caches/heroku
~/.heroku doesn't exist. ππ»
I'll let you know if something happens again. Thanks for playing along.
> heroku run rails console
Updating plugins, node version changed to 9.7.1... !
βΈ Cannot read property 'map' of undefined
Updating plugins, node version changed to 9.7.1... !
βΈ Cannot read property 'map' of undefined
Updating plugins, node version changed to 9.7.1... done
Running rails console on β¬’ MYAPP... up, run.4751 (Standard-1X)
> heroku run rails console
module.js:557
throw err;
^
Error: Cannot find module '/Users/s/.local/share/heroku/client/bin/heroku.js'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:618:3
==> Command ["heroku run rails console"] failed
π΅
This is the bug that never ends,
it goes on and on, my friends.
Something started causing it,
not knowing what it was,
and it'll continue causing it forever just becauseβ¦
@veganstraightedge I think you're best bet is doing a full uninstall and re-install.
Uninstall:
$ rm -rf ~/.local/share/heroku
$ rm -fr ~/Library/Caches/heroku
$ rm -fr ~/.heroku # may not exist
$ rm -fr ~/.config/heroku # may not exist
$ brew uninstall --force heroku # remove all previous downloaded versions
$ gem uninstall heroku # may return nothing (very old cli)
Re-install (notice the tap name):
$ brew install heroku/brew/heroku
Hopefully that solves it, but let me know how it goes!
Only the first two existed. Blew them all away.
rm -rf ~/.local/share/heroku
rm -fr ~/Library/Caches/heroku
rm -fr ~/.heroku
rm -fr ~/.config/heroku
brew uninstall heroku
brew install heroku/brew/heroku
@veganstraightedge Are the errors persisting or did that seem to fix it? If not, we may want to deep dive into your directories.
It seems fine now. But that's how it always goes. If you don't hear from me in a couple weeks then we can prolly close this.
Just for the record, @veganstraightedge you are not alone. This happens to me periodically, and I uninstall/reinstall heroku via homebrew and it will resume working for awhile.
I'll try the steps you did 13 days ago and see if they help me.
eventually a few other users reported this as well, I put some more instructions on https://github.com/heroku/cli/issues/653 and potentially shipped a fix for it
@mckoon @jdxcode FWIW, I haven't seen any of these kind of errors since that last batch of sledgehammer uninstall/install instructions. Good luck!
Thanks again for all your work on this issue. I really appreciate it, especially because I use the heroku cli dozens of times every day. β€οΈ
sorry it was such a pain to get it resolved! This was definitely the most difficult issue we've dealt with in a long time
// β₯ heroku login
WARNING
WARNING Node version must be >=8.0.0 to use this CLI
WARNING Current node version: 6.11.2
WARNING
/Users/charlielee/.nvm/versions/node/v6.11.2/lib/node_modules/heroku-cli/node_modules/@oclif/command/lib/command.js:23
async _run() {
^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.
I just got this heroku update error running on macOS High Sierra. It attempted to do two CLI updates with one command execution before I got this error. I will go through these comments to see if I can fix the problem.
heroku-cli: Updating CLI from 6.15.18-fdf2097 to 6.99.0-ec9edad... done
heroku-cli: Updating CLI from 6.99.0-ec9edad to 7.0.22... done
heroku: migrating plugins
heroku-cli: migrating heroku-pg-extras
yarn add v1.6.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 83 new dependencies.
info Direct dependencies
ββ [email protected]
info All dependencies
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
Done in 8.76s.
Installing plugin heroku-pg-extras... done
heroku-cli: migrating heroku-repo
yarn add v1.6.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 14 new dependencies.
info Direct dependencies
ββ [email protected]
info All dependencies
ββ @heroku-cli/[email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
ββ [email protected]
Done in 3.97s.
Installing plugin heroku-repo... done
heroku: done migrating plugins
heroku: Updating CLI... already on latest version: 7.0.22
module.js:557
throw err;
^
Error: Cannot find module './errors'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at fetch (/Users/server1/.local/share/heroku/client/6.15.18-fdf2097/node_modules/cli-ux/lib/deps.js:22:20)
at Object.get Errors [as Errors] (/Users/server1/.local/share/heroku/client/6.15.18-fdf2097/node_modules/cli-ux/lib/deps.js:12:27)
at CLI.get Errors [as Errors] (/Users/server1/.local/share/heroku/client/6.15.18-fdf2097/node_modules/cli-ux/lib/index.js:24:47)
at action.pause (/Users/server1/.local/share/heroku/client/6.15.18-fdf2097/node_modules/cli-ux/lib/index.js:65:25)
at SpinnerAction.pause (/Users/server1/.local/share/heroku/client/6.15.18-fdf2097/node_modules/cli-ux/lib/action/base.js:100:21)
at CLI.error (/Users/server1/.local/share/heroku/client/6.15.18-fdf2097/node_modules/cli-ux/lib/index.js:64:21)
@lightbe is that the only error you saw? I wouldn't go through any of these steps. It shouldn't happen again
@jdxcode yes it was. I just removed ~/.local/share/heroku/client/bin/heroku.js and successfully executed heroku update. When I ran the command I saw heroku: Updating CLI... already on latest version: 7.0.22.
The bug you saw has nothing to do with the others in this ticket. It's not even a real bug, there were just some releases that threw an error after it completed updating. It's not the case now and it still updated successfully
I had no idea what caused the throw error. I realize that I had a very old version of heroku cli. I installed it when I first started using Heroku I think in 2016 or whenever I updated my server to macOS Sierra and quit using Phusion Passenger for hosting my Rails applications. This was the first time in months I executed a heroku command and saw the message about a newer version. I have executed other heroku commands successfully.