Skip to content

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

Open
@EdgarsGarsneks

Description

@EdgarsGarsneks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions