[英]'.' 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 以防萬一。
在@derpirscher 的幫助下解決。
const path = require("path");
const prismaBinary = "./node_modules/.bin/prisma";
await exec(
`${path.resolve(prismaBinary)} migrate up --create-db --experimental`
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.