我正在尝试创建一个 Makefile 来运行我的 React 应用程序的测试套件。在根文件夹中,React 应用程序位于 frontend/
。
我可以用什么make命令来实现这个?我尝试了以下但没有运气:
test-frontend:
cd ./frontend/
npm test
test-frontend:
npm test ./frontend/
test-frontend:
cd ./frontend/
npm run-script test
这是我得到的错误:
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /path/to/dir/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/path/to/dir/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /$HOME/.npm/_logs/2019-10-24T02_23_23_195Z-debug.log
make: *** [test-frontend] Error 254
最佳答案
评论回答了我的问题。答案是:
test-frontend:
cd ./frontend/ && npm run-script test
或者如果您想使用单独的行以提高可读性:
test-frontend:
cd ./frontend/ && \
npm run-script test
关于reactjs - Makefile 命令在子文件夹中运行 react 测试套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58532803/