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

ng --version errors without node_modules dir #10917

Closed
davidkassa opened this issue May 18, 2018 · 7 comments
Closed

ng --version errors without node_modules dir #10917

davidkassa opened this issue May 18, 2018 · 7 comments

Comments

@davidkassa
Copy link

davidkassa commented May 18, 2018

Versions

debian jesse FROM node:latest

$ node --version
v10.1.0
$ npm --version
5.6.0
success Installed "@angular/[email protected]" with binaries

Repro steps

Using GitLab CI:

image: davidkassa/yarn-angular-cli-firebase-tools:latest
before_script:
 - node --version
 - npm --version
 - ng --version

Observed behavior

$ ng --version
ENOENT: no such file or directory, scandir '/builds/davidkassa/shot-club-web/node_modules'
Error: ENOENT: no such file or directory, scandir '/builds/davidkassa/shot-club-web/node_modules'
    at Object.fs.readdirSync (fs.js:875:3)
    at VersionCommand.run (/usr/local/share/.config/yarn/global/node_modules/@angular/cli/commands/version.js:48:19)
    at /usr/local/share/.config/yarn/global/node_modules/@angular/cli/models/command-runner.js:278:30
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/share/.config/yarn/global/node_modules/@angular/cli/models/command-runner.js:4:58)
ERROR: Job failed: exit code 1

Desired behavior

I would expect version information to be given even if there is not a node_modules/ directory present

Mention any other details that might be useful (optional)

@jhgjhtuytdfbnfvmnbgjtuydt
Copy link

jhgjhtuytdfbnfvmnbgjtuydt commented Jun 19, 2018

I am getting that same error:

ENOENT: no such file or directory, scandir '/Users/david/repos/halo/frontend/node_modules'
Error: ENOENT: no such file or directory, scandir '/Users/david/repos/halo/frontend/node_modules'
    at Object.fs.readdirSync (fs.js:904:18)
    at VersionCommand.run (/Users/david/.config/yarn/global/node_modules/@angular/cli/commands/version.js:48:19)
    at /Users/david/.config/yarn/global/node_modules/@angular/cli/models/command-runner.js:278:30
    at Generator.next (<anonymous>)
    at fulfilled (/Users/david/.config/yarn/global/node_modules/@angular/cli/models/command-runner.js:4:58)
    at <anonymous>

The only cause I can think of is of mixing both npm and yarn to install/uninstall packages?

I have been unsuccessfully trying to upgrade from angular 5 to angular 6. Now I am trying to do a fallback. Nothing is working

@ngbot ngbot bot added this to the needsTriage milestone Jan 24, 2019
@collinbarrett
Copy link

I am getting this error on my WIndows dev box when calling ng --version or ng version...

@michael-lang
Copy link

I have the same problem, but the error message is different. In my case, @angular/cli was installed globally with yarn instead of npm. This command is run from VSCode terminal window. Is this a powershell compatibility issue?

PS C:\Users\mlang> ng --version
At C:\Users\mlang\AppData\Local\Yarn\bin\ng.ps1:5 char:13
+     *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+             ~
Unexpected token ')' in expression or statement.
At C:\Users\mlang\AppData\Local\Yarn\bin\ng.ps1:8 char:3
+ if [ -x "$basedir/pwsh" ]; then
+   ~
Missing '(' after 'if' in if statement.
At C:\Users\mlang\AppData\Local\Yarn\bin\ng.ps1:8 char:5
+ if [ -x "$basedir/pwsh" ]; then
+     ~
Missing type name after '['.
At C:\Users\mlang\AppData\Local\Yarn\bin\ng.ps1:9 char:20
+ ... asedir/pwsh"  "$basedir/../Data/global/node_modules/.bin/ng.ps1" "$@"
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"$basedir/../Data/global/node_modules/.bin/ng.ps1"' in expression or statement.
At C:\Users\mlang\AppData\Local\Yarn\bin\ng.ps1:9 char:71
+ ... asedir/pwsh"  "$basedir/../Data/global/node_modules/.bin/ng.ps1" "$@"
+                                                                      ~~~~
Unexpected token '"$@"' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

It does work from within cygwin or the windows command prompt

C:\WINDOWS\system32>ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.3.1
Node: 10.15.0
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.13.1
@angular-devkit/core         7.3.1
@angular-devkit/schematics   <error>
@schematics/angular          <error>
@schematics/update           <error>
rxjs                         6.3.3

Should this be reported in a separate bug report, related to powershell compatibility?

@baembry
Copy link

baembry commented Aug 4, 2019

I had the same issue and solved it by changing to the root directory [cd ~/] and then running ng --version

@bgotink
Copy link
Contributor

bgotink commented Feb 14, 2020

This happens in yarn 2 plug-n-play set ups as well, because there's no longer a node_modules folder in projects using yarn 2.

@alan-agius4
Copy link
Collaborator

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants