AhsanAyaz / AhsanAyaz/angular-deploy-gh-pages-actions
Windows runner 'node_modules' is not recognized as an internal or external command
- 主要語言
- HTML
- 星號
- 62
- 分支
- 23
- PR 合併指標
- 30 天內沒有已合併 PR
描述
## Issue
When I was running this step on self-hosted windows runner (same for `windows-latest`) this action failed wit not recognized command error:
```bash
Creating ng build 💪
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
Error: Command failed: node_modules/.bin/ng build --configuration=staging --base-href=/demo/
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
```
## Steps to reproduce
Change in GitHub workflow file `os` to `windows-latests`. This PR contains reproduced error => https://github.com/EdgarsGarsneks/angular-deploy-gh-pages-actions/pull/2
## Root Cause
Issue is in the command that is being generated it is referencing `node_modules/.bin/ng` which Windows tries to resolve when running in cmd and fails because of forward slash usage. 🤦♂️
```bash
(1) C:\demo>node_modules/.bin/ng <=== Current command
'node_modules' is not recognized as an internal or external command,
operable program or batch file.
```
```bash
(2) C:\demo>./node_modules/.bin/ng <=== Relative path, same error
'.' is not recognized as an internal or external command,
operable program or batch file.
```
```bash
C:\demo>node_modules\.bin\ng version <=== Backward slash, Ok!
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 17.0.1
```
## Solution Proposal
As this project is not executing any `npm` step proposal would be to use built-in [npx](https://docs.npmjs.com/cli/v8/commands/npx). Which would find and execute appropriate binary in the project path. In result changing commands for build and lint to should solve the problem.
```bash
npx ng build --configuration=staging --base-href=/demo/
npx ng lint
```
Linked PR contains mentioned change and also change to workflow file to include tests on `windows` and `mac` runners.
Only thing to mention that in order not have race conditions when uploading to gh-pages branch matrix was configured to run without concurrency which will increase total time. To speed up things seperate branches could be used. But I doubt that it would bring any value there. Let me know if I missed something or if you see any simpler solution 😃 🚀!
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。