@angular/cli gives error if node_modules is placed in parent folder
See original GitHub issueProbably 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 folderng 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
- Issue should’ve been fixed based on this commit https://github.com/angular/angular-cli/issues/3864#issuecomment-409318373 which is merged in 6.1.2
- https://github.com/Magnetars/node-modules-parent-folder.git
- The project is a base ng project, no other modules are added. (You could create a new project instead of cloning)
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
is changed to point to"$schema": "../node_modules/@angular/cli/lib/config/schema.json",
(…/node_modules instead of ./node_modules)
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:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 regressedThis 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.