Skip to content

@angular/cli gives error if node_modules is placed in parent folder #11823

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
Magnetars opened this issue Aug 8, 2018 · 5 comments
Closed

@angular/cli gives error if node_modules is placed in parent folder #11823

Magnetars opened this issue Aug 8, 2018 · 5 comments

Comments

@Magnetars
Copy link

Probably related to #3864

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

node version: v8.11.3
npm version: 5.5.1

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


Angular CLI: 6.1.2
Node: 8.11.3
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.2
@angular-devkit/core         0.7.2
@angular-devkit/schematics   0.7.2
@schematics/angular          0.7.2
@schematics/update           0.7.2
rxjs                         6.2.2
typescript                   2.7.2

Repro steps

  • Clone the project (project is generated with angular-cli, no other modules are added)
  • npm install in parent folder (node-modules-parent-folder)
  • cd frontend for angular project folder
  • ng serve to build and run

The log given by the failure

You seem to not be depending on "@angular/core" and/or "rxjs". This is an error.

Desired functionality

It should automatically navigate to parent folder (as per node resolution) and find the @angular/core and rxjs.

Mention any other details that might be useful

Please note that while this could simply be solved by installing the node_modules in the Angular project folder, since my project is using server-side-rendering (using Angular Universal), it's more convenient to have the node_modules in the parent folder shared by both frontend and backend

My project structure is something like this:

+-- node-modules-parent-folder <-------- project folder
|     +-- package.json <-------------------- package.json moved to parent folder
|     +-- node_modules
|     +-- frontend <------------------------ Angular project goes here
|           +-- angular.json
|     +-- backend  <------------------------ Server code goes here
|          +-- server.js
@Magnetars Magnetars changed the title @angular/cli does gives error if node_modules is placed in parent folder @angular/cli gives error if node_modules is placed in parent folder Aug 8, 2018
@jSchez
Copy link

jSchez commented Aug 9, 2018

You can try using version < 6.1.0 and it will work. I think this issue is the same as this https://github.com/angular/angular-cli/issues/11685

@Magnetars
Copy link
Author

Indeed you are right, but instead I went with temporarily having node_modules in both the Angular project folder and the parent project folder, this way I can keep developing against the latest version (6.1.2 as of now) to avoid any sudden happy surprises if I migrate through multiple versions later.

But for people whom this is not a viable solution (I believe people using Docker can't install node_modules in the Angular project folder), then you should go with version < 6.1.0 as mentioned by @jSchez since that's where the problem first regressed

@jSchez
Copy link

jSchez commented Aug 9, 2018

I hope that they fix this .. monorepos are really cool and I don’t like experimenting either because as you mention, they may change the way it works and then you will habe to redo everything again 😥

@alexeagle
Copy link
Contributor

Thanks all, I agree it's a dupe of #11685 looks like we need a test case for this

@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants