node.jsbashnpmvisual-studio-codeeval

'eval' is not recognized as an internal or external command, operable program or batch file on windows npm script


$ npm run deploy:local

> [email protected] deploy:local
> eval "`aws-auth-helper ` lerna run deploy:sandbox --stream"

'eval' is not recognized as an internal or external command,
operable program or batch file.

Node version:

$ node --version
v15.11.0

NPM version:

$ npm --version
7.6.0

I am using VSCode Bash terminal. It had been working just fine but then I started getting this error. Have tried both bash terminal and javascript terminal.

If I just type "eval" in the bash terminal, it works okay. While running through npm script it does not.


Solution

  • Since you are on a Windows environment, even if the shell you're executing from is bash, npm will likely be executing the run script in the default shell of Windows (PS now, I think?).

    You could try modifying your package.json file in this way

    Note that if bash is not in your PATH, you'll have to use the full path

    {
    //... other keys
      "scripts" : {
        //... other keys
        "deploy" : "bash -c \"eval `aws-auth-helper ` lerna run deploy:sandbox --stream\" "
      }
    }