Search code examples
visual-studio-codeterminalzshfishfirebase-tools

VSCode intergrated terminal fails to execute command, but system terminal executes same command correctly


M1 Mac system terminal firebase emulators:start works as expected.

But VSCode integrated terminal errors on the same command (error given below).

How can I fix this?

If it matters, I use both Fish and Zsh, and the behavior is consistent for both: both Fish and Zsh run the firebase command in the Mac Terminal app, but not from VSCode's integrated terminal.

Error given when running firebase from VSCode integrated terminal:

internal/modules/cjs/loader.js:59
const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
                                                               ^

TypeError: require(...).internalModuleStat is not a function
    at internalModuleStat (internal/modules/cjs/loader.js:59:64)
    at stat (internal/modules/cjs/loader.js:143:18)
    at Function.Module._findPath (internal/modules/cjs/loader.js:645:16)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:951:27)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1024:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1276:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:444:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:76:3)
    at internal/bootstrap/pkg.js:7:1

Solution

  • There was a bug with a setting in settings.json: "debug.javascript.autoAttachFilter": "onlyWithFlag", caused the error above.

    I found this by iteratively bisecting my settings (i.e. commenting out half at a time) until I found the one that broke the firebase command.

    I've raised an issue in the github repo, since there's no obvious reason that this setting should affect commands on the $PATH variable. https://github.com/microsoft/vscode/issues/150373