Skip to content

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

Closed
@Magnetars

Description

@Magnetars

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions