Skip to content

ng new fails if there is a node_modules directory with angular-cli in the parent dir. #2326

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

Closed
MikeWay opened this issue Sep 24, 2016 · 4 comments
Labels
P5 The team acknowledges the request but does not plan to address it, it remains open for discussion type: bug/fix

Comments

@MikeWay
Copy link

MikeWay commented Sep 24, 2016

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
    Win 10
  2. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.
  1. Slightly unusual in that I'm tryin to share a single node_modules across multiple projects so have node_modules in the parent directory of the one I'm trying to create the project in (created previously with the same versions and moved to the parent directory). (I create projects with --skip-npm = true then create a symlink).

  2. Failure occurs using ng new XXXXX

  3. Workaround is to rename the node_modules in the parent project. The revert node_modules name and create symlink which works fine.

Dir structure

// root / myFolder / node_modules ----< Renaming this temporarily is the work around
/ DoNows -- Run ng new in here
/ XXXX -- created OK once node_modules renamed

  1. The log given by the failure. Normally this include a stack trace and some
    more information.

C:\course2324\DoNows>ng new Breaks
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^

TypeError: path must be a string
at TypeError (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Function.Version.fromProject (C:\Users\student\AppData\Roaming\npm\node_modules\angular-cli\upgrade\version.js:87:31)
at Function.Version.isPreWebpack (C:\Users\student\AppData\Roaming\npm\node_modules\angular-cli\upgrade\version.js:111:31)
at Function.Version.assertPostWebpackVersion (C:\Users\student\AppData\Roaming\npm\node_modules\angular-cli\upgrade\version.js:97:18)
at C:\Users\student\AppData\Roaming\npm\node_modules\angular-cli\bin\ng:25:15
at C:\Users\student\AppData\Roaming\npm\node_modules\angular-cli\node_modules\resolve\lib\async.js:44:21
at ondir (C:\Users\student\AppData\Roaming\npm\node_modules\angular-cli\node_modules\resolve\lib\async.js:187:31)
at C:\Users\student\AppData\Roaming\npm\node_modules\angular-cli\node_modules\resolve\lib\async.js:153:39

  1. Mention any other details that might be useful.

Thanks! We'll be in touch soon.

@filipesilva
Copy link
Contributor

Hm, this has to do with how the global CLI finds the local CLI. Still the errors shouldn't be so obscure.

@filipesilva filipesilva added type: bug/fix command: new P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Oct 3, 2016
@vpithart
Copy link

vpithart commented Oct 4, 2016

Additional report for the same bug:

OS?

OS X El Capitan 10.11.6 (15G1004)

Versions.

angular-cli: 1.0.0-beta.16
node: 4.4.7
os: darwin x64

Repro steps.

Situation:

  • ng installed system-wide as symlink: /usr/local/bin/ng -> ../lib/node_modules/angular-cli/bin/ng
  • standing in a very empty directory /tmp/foobarproject
  • ng just works (the bare ng shows the help - Usage: ng <command (Default: help)> and so on)
  • The angular-cli is also installed system-wide in /usr/local/lib/node_modules/angular-cli/

Steps:

  • Run $ npm install angular-cli, this creates node_modules direcotry with angular-cli in it, plus ~950 others (dependencies)
  • Run ng, it fails

The log given by the failure.

fs.js:549
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

TypeError: path must be a string
    at TypeError (native)
    at Object.fs.openSync (fs.js:549:18)
    at Object.fs.readFileSync (fs.js:397:15)
    at Function.Version.fromProject (/usr/local/lib/node_modules/angular-cli/upgrade/version.js:87:31)
    at Function.Version.isPreWebpack (/usr/local/lib/node_modules/angular-cli/upgrade/version.js:111:31)
    at Function.Version.assertPostWebpackVersion (/usr/local/lib/node_modules/angular-cli/upgrade/version.js:97:18)
    at /usr/local/lib/node_modules/angular-cli/bin/ng:25:15
    at /usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:44:21
    at ondir (/usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:187:31)
    at /usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:153:39

Mention any other details that might be useful.

This was my first painful experience with the ng command :-(

@filipesilva
Copy link
Contributor

Fixed in #2178

@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 Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P5 The team acknowledges the request but does not plan to address it, it remains open for discussion type: bug/fix
Projects
None yet
Development

No branches or pull requests

3 participants