'.'不被识别为在 exec() 中使用时抛出的内部或外部命令,但在命令行中使用 运行 时则不会
'.' is not recognized as an internal or external command thrown when used in exec(), but not when run from command line
以下是 运行 使用 npm 运行 测试的脚本的一部分。
async setup() {
process.env.DATABASE_URL = this.databaseUrl;
this.global.process.env.DATABASE_URL = this.databaseUrl;
await exec(`./node_modules/.bin/prisma migrate up --create-db --experimental`);
return super.setup();}
这将引发以下错误
Command failed: ./node_modules/.bin/prisma migrate up --create-db --experimental
'.' is not recognized as an internal or external command,
operable program or batch file.
当 运行 来自 cmd 时,命令按预期工作。在 exec() 中引用二进制文件的正确方法是什么?我正在使用相关的 windows incase。
在@derpirscher 的帮助下解决。
const path = require("path");
const prismaBinary = "./node_modules/.bin/prisma";
await exec(
`${path.resolve(prismaBinary)} migrate up --create-db --experimental`
);
以下是 运行 使用 npm 运行 测试的脚本的一部分。
async setup() {
process.env.DATABASE_URL = this.databaseUrl;
this.global.process.env.DATABASE_URL = this.databaseUrl;
await exec(`./node_modules/.bin/prisma migrate up --create-db --experimental`);
return super.setup();}
这将引发以下错误
Command failed: ./node_modules/.bin/prisma migrate up --create-db --experimental
'.' is not recognized as an internal or external command,
operable program or batch file.
当 运行 来自 cmd 时,命令按预期工作。在 exec() 中引用二进制文件的正确方法是什么?我正在使用相关的 windows incase。
在@derpirscher 的帮助下解决。
const path = require("path");
const prismaBinary = "./node_modules/.bin/prisma";
await exec(
`${path.resolve(prismaBinary)} migrate up --create-db --experimental`
);