Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows runner 'node_modules' is not recognized as an internal or external command #78

Open
EdgarsGarsneks opened this issue Jan 28, 2024 · 0 comments

Comments

@EdgarsGarsneks
Copy link

Issue

When I was running this step on self-hosted windows runner (same for windows-latest) this action failed wit not recognized command error:

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 => EdgarsGarsneks#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. 🤦‍♂️

(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.
(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.
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. Which would find and execute appropriate binary in the project path. In result changing commands for build and lint to should solve the problem.

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 😃 🚀!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant