Skip to content

angular-cli doesn't work when node_modules is located in a parent directory #3864

Closed
@euangoddard

Description

@euangoddard

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Alpine linux (inside Docker container)

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
1.0.0-beta.24

but running ng --version gives:

Cannot find module '/opt/app/ngapp/node_modules/@angular/common/package.json'
Error: Cannot find module '/opt/app/ngapp/node_modules/@angular/common/package.json'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Class.getVersion (/opt/app/node_modules/angular-cli/commands/version.js:67:25)
    at /opt/app/node_modules/angular-cli/commands/version.js:63:67
    at Array.forEach (native)
    at Class.getDependencyVersions (/opt/app/node_modules/angular-cli/commands/version.js:63:14)
    at /opt/app/node_modules/angular-cli/commands/version.js:41:58
    at Array.forEach (native)
    at Class.run (/opt/app/node_modules/angular-cli/commands/version.js:40:19)
    at Class.<anonymous> (/opt/app/node_modules/angular-cli/ember-cli/lib/models/command.js:152:17)
    at process._tickCallback (internal/process/next_tick.js:103:7)

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

  1. ng new ngapp
  2. cd ngapp
  3. mv node_modules ..
  4. ng build

The log given by the failure.

Normally this include a stack trace and some more information.

You seem to not be dependending on "@angular/core". This is an error.

Mention any other details that might be useful.

I want to use angular CLI inside a docker container using docker-compose. I cannot have the node_modules folder inside the source code and a common pattern to solve this issue is to move the node_modules folder to the parent directory. Node will correctly recognise dependencies, but for some reason angular CLI is failing to find the @angular/core package.

If I run node and then do require('@angular/core') the package is correctly loaded.

Metadata

Metadata

Assignees

Labels

P5The team acknowledges the request but does not plan to address it, it remains open for discussion

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions