question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Probably related to https://github.com/angular/angular-cli/issues/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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Magnetarscommented, Aug 9, 2018

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

0reactions
angular-automatic-lock-bot[bot]commented, Sep 8, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng serve is checking nodemodules in previous directory
1 Answer 1 ; Node modules are present in current directory but it is not checking curent directory. – Venkatesh Voona. May 29,...
Read more >
Workspace npm dependencies - Angular
The Angular Framework, Angular CLI, and components used by Angular applications are packaged as npm packages and distributed using the npm registry.
Read more >
Deployment - Angular
When you are ready to deploy your Angular application to a remote server, you have various options for deployment. Simple deployment optionslink.
Read more >
ng test - Angular
Option Description Value Type Defau... ‑‑browsers Override which browsers tests are run against. string ‑‑code‑coverage Output a code coverage report. boolean false ‑‑code‑coverage‑exclude Globs to exclude...
Read more >
Server-side rendering (SSR) with Angular Universal
This means that the application generally renders more quickly, giving users a chance ... the Angular CLI compiles and bundles the Universal version...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found