【发布时间】:2021-03-17 00:52:08
【问题描述】:
我正在使用 Windows 机器开发一个项目,并且我有一些这样的 npm 脚本:
"start" : "./foo/bar"
当我尝试运行 npm run start 时出现此错误:
.\foo\bar is not recognized as an internal or external command,
operable program or batch file.
我注意到正斜杠已被翻转为 Windows 的反斜杠,但如果我自己运行此命令,bash 终端会将它们作为“转义”中断并返回:
bash: .foobar: command not found
如果我使用 ./foo/bar 或 .\\foo\\bar,文件在终端中运行正常,但如果我在 npm 脚本中使用它们,则不会。
我该怎么做才能让它在 Windows 中运行?此外,有没有办法将其编写为与 Win/Mac/Linux 兼容?
【问题讨论】:
标签: npm terminal npm-scripts