【问题标题】:'eval' is not recognized as an internal or external command, operable program or batch file on windows npm script'eval' 在 windows npm 脚本上不是内部或外部命令、可运行程序或批处理文件
【发布时间】:2021-03-24 23:16:26
【问题描述】:
$ npm run deploy:local

> backend@0.1.0 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
v15.11.0

NPM 版本:

$ npm --version
7.6.0

我正在使用 VSCode Bash 终端。它一直工作得很好,但后来我开始收到这个错误。 bash终端和javascript终端都试过了。

如果我只是在 bash 终端中键入“eval”,它就可以正常工作。通过 npm 脚本运行时不会。

【问题讨论】:

  • 似乎您正在使用为批处理/cmd 中的 bash 设计的命令。 linux 的 bash 和 windows 的 batch 有很大的不同。请确保您实际使用的是后者。
  • @Socowi 我正在使用 stackoverflow.com/a/50527994/2699001 。我需要切换到其他东西吗?
  • 我不知道。在 Windows 中没有预装 bash。因此,我不知道您是否可以 switch 到 bash。您可能必须先安装 WSL、git-bash、cygwin 或类似的东西。
  • 目前正在使用的实际上是 git-bash,我的印象是它曾经可以正常工作
  • is not recognized as an internal or external command, operable program or batch file. 是 cmd 遇到未知命令时的消息。我不知道 node.js,但你要么写一个 cmd 命令,要么以某种方式更改 node.js 的默认 shell,或者从 cmd 调用 bash

标签: node.js bash npm visual-studio-code eval


【解决方案1】:

由于您在 Windows 环境中,即使您正在执行的 shell 是 bash,npm 也可能会在 Windows 的默认 shell 中执行运行脚本(现在 PS,我想?)。

如果bash 在您的PATH 变量(1) 中,您可以尝试以这种方式修改您的package.json 文件:

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

(1) 或者使用bash.exe的完整路径

【讨论】:

    猜你喜欢
    • 2014-01-26
    • 1970-01-01
    • 2021-02-11
    • 1970-01-01
    • 1970-01-01
    • 2019-10-04
    • 1970-01-01
    • 2023-04-05
    • 2018-08-25
    相关资源
    最近更新 更多