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

TypeError: Cannot read property 'config' of null #4736

Closed
soodvarun opened this Issue Feb 16, 2017 · 59 comments

Comments

Projects
None yet
@soodvarun

soodvarun commented Feb 16, 2017

Please provide us with the following information:

OS?

Windows 7

Versions.

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

@angular/cli: 1.0.0-beta.31
node: 6.9.4
os: win32 x64
@angular/cli: 1.0.0-beta.31
@angular/common: 2.2.4
@angular/compiler: 2.2.4
@angular/compiler-cli: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.2.4
@angular/http: 2.2.4
@angular/platform-browser: 2.2.4
@angular/platform-browser-dynamic: 2.2.4
@angular/router: 3.2.4
@angular/upgrade: 2.2.4

Repro steps.

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

Added cli later and did ng init

The log given by the failure.

Normally this include a stack trace and some more information.

ng build --prod --verbose
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
   at Class.run (C:\Projects\Someplace\Portal\Someplace\node_modules\@angular\cli\tasks\build.js:14:89)
   at Class.run (C:\Projects\Someplace\Portal\Someplace\node_modules\@angular\cli\commands\build.js:49:26)
   at Class.<anonymous> (C:\Projects\Someplace\Portal\Someplace\node_modules\@angular\cli\ember-cli\lib\models\command.js:134:17)
   at process._tickCallback (internal/process/next_tick.js:103:7)

Mention any other details that might be useful.

The offending line
const outputPath = runTaskOptions.outputPath || config_1.CliConfig.fromProject().config.apps[0].outDir;


Thanks! We'll be in touch soon.

@ardiadrianadri

This comment has been minimized.

Show comment
Hide comment
@ardiadrianadri

ardiadrianadri Feb 16, 2017

I know why it is happening but I don't know how to solved. The problem is that the transpiled JS code remove the "." at the beginning of the string ".angular-cli.json", so angular-cli cannot find the configuration file because it is looking for a file that doesn't exist. Let me show you:

This is the content of packages/@angular/cli/models/config.ts:

(...)
import * as chalk from 'chalk';
import * as fs from 'fs';
import * as path from 'path';

export const CLI_CONFIG_FILE_NAME = '.angular-cli.json';
const CLI_CONFIG_FILE_NAME_ALT = 'angular-cli.json';
(..)

As you can see, the variable CLI_CONFIG_FILE_NAME stores the name of the angular-cli configuration file that is in the root path of your project. However, once you create a new project with angular-cli, the same variable has another value:

node_modules/@angular/cli/models/config.js

(...)
const chalk = require('chalk');
const fs = require('fs');
const path = require('path');
exports.CLI_CONFIG_FILE_NAME = 'angular-cli.json';
function _findUp(name, from) {
(...)

The "." of ".angular-cli.json" has gone. This is the reason why we are getting a null in the config, because angular-cli is looking for 'angular-cli.json' but the real file is .angular-cli.json. I don't know why it is happening. My guess is that there is a problem with the TypeScript configuration but I'm not sure.

The workaround is easy. First, change the name of the ".angular-cli.json" in the root folder for "angular-cli.json". After that, add the property app.environments.sorce with the relative path of the environment configuration file that you want use by default:

"environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
 }

I hope this helps.

ardiadrianadri commented Feb 16, 2017

I know why it is happening but I don't know how to solved. The problem is that the transpiled JS code remove the "." at the beginning of the string ".angular-cli.json", so angular-cli cannot find the configuration file because it is looking for a file that doesn't exist. Let me show you:

This is the content of packages/@angular/cli/models/config.ts:

(...)
import * as chalk from 'chalk';
import * as fs from 'fs';
import * as path from 'path';

export const CLI_CONFIG_FILE_NAME = '.angular-cli.json';
const CLI_CONFIG_FILE_NAME_ALT = 'angular-cli.json';
(..)

As you can see, the variable CLI_CONFIG_FILE_NAME stores the name of the angular-cli configuration file that is in the root path of your project. However, once you create a new project with angular-cli, the same variable has another value:

node_modules/@angular/cli/models/config.js

(...)
const chalk = require('chalk');
const fs = require('fs');
const path = require('path');
exports.CLI_CONFIG_FILE_NAME = 'angular-cli.json';
function _findUp(name, from) {
(...)

The "." of ".angular-cli.json" has gone. This is the reason why we are getting a null in the config, because angular-cli is looking for 'angular-cli.json' but the real file is .angular-cli.json. I don't know why it is happening. My guess is that there is a problem with the TypeScript configuration but I'm not sure.

The workaround is easy. First, change the name of the ".angular-cli.json" in the root folder for "angular-cli.json". After that, add the property app.environments.sorce with the relative path of the environment configuration file that you want use by default:

"environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
 }

I hope this helps.

@bougnat12

This comment has been minimized.

Show comment
Hide comment
@bougnat12

bougnat12 Feb 20, 2017

I have the same issue after installing @angular/cli 1.0.0-beta.32.3 package but it was caused by the remaining angular-cli 1.0.0-28.3 package in my package.json file! After removing it everything works well. (when exploring my app node_modules directory I found @angular/cli, @angular-cli and angular-cli sub directories - this why I found the solution...)

Hope that helps

bougnat12 commented Feb 20, 2017

I have the same issue after installing @angular/cli 1.0.0-beta.32.3 package but it was caused by the remaining angular-cli 1.0.0-28.3 package in my package.json file! After removing it everything works well. (when exploring my app node_modules directory I found @angular/cli, @angular-cli and angular-cli sub directories - this why I found the solution...)

Hope that helps

@jdschmitt

This comment has been minimized.

Show comment
Hide comment
@jdschmitt

jdschmitt Feb 26, 2017

I am seeing this issue. Never install angular cli before now so it's not a collision with older version. I've got "@angular/cli": "^1.0.0-rc.0" in package.json.

> ng serve
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
at Class.run (/Users/jason/Development/repos/shield/node_modules/@angular/cli/tasks/serve.js:22:63)
at check_port_1.checkPort.then.port (/Users/jason/Development/repos/shield/node_modules/@angular/cli/commands/serve.js:103:26)
at process._tickCallback (internal/process/next_tick.js:103:7)

I can see that a change has been made to account for the 2 file names as pointed out above:

...
const path = require("path");
const find_up_1 = require("../utilities/find-up");
exports.CLI_CONFIG_FILE_NAME = '.angular-cli.json';
const CLI_CONFIG_FILE_NAME_ALT = 'angular-cli.json';
function getUserHome() {
...

Am I supposed to create that file myself? I can find one here node_modules/@angular/cli/blueprints/ng/files/angular-cli.json but I doubt that's the one it's supposed to be looking for.

jdschmitt commented Feb 26, 2017

I am seeing this issue. Never install angular cli before now so it's not a collision with older version. I've got "@angular/cli": "^1.0.0-rc.0" in package.json.

> ng serve
Cannot read property 'config' of null
TypeError: Cannot read property 'config' of null
at Class.run (/Users/jason/Development/repos/shield/node_modules/@angular/cli/tasks/serve.js:22:63)
at check_port_1.checkPort.then.port (/Users/jason/Development/repos/shield/node_modules/@angular/cli/commands/serve.js:103:26)
at process._tickCallback (internal/process/next_tick.js:103:7)

I can see that a change has been made to account for the 2 file names as pointed out above:

...
const path = require("path");
const find_up_1 = require("../utilities/find-up");
exports.CLI_CONFIG_FILE_NAME = '.angular-cli.json';
const CLI_CONFIG_FILE_NAME_ALT = 'angular-cli.json';
function getUserHome() {
...

Am I supposed to create that file myself? I can find one here node_modules/@angular/cli/blueprints/ng/files/angular-cli.json but I doubt that's the one it's supposed to be looking for.

@dpalita

This comment has been minimized.

Show comment
Hide comment
@dpalita

dpalita Feb 26, 2017

It also happens if the project is in the home directory (something related to global config file being the same as the project config file)... in my case it was because I used to mount the project in the home of a docker user for building.

dpalita commented Feb 26, 2017

It also happens if the project is in the home directory (something related to global config file being the same as the project config file)... in my case it was because I used to mount the project in the home of a docker user for building.

@labs-scnm

This comment has been minimized.

Show comment
Hide comment
@labs-scnm

labs-scnm Feb 27, 2017

I got this error on an Docker build. I set the HOME env to the same directory as the project root. That's why the configPath and this.globalConfigFilePath() are the same and returned every time with null. 😒

const configPath = this.configFilePath(projectPath);
if (!configPath || configPath === this.globalConfigFilePath()) {
  return null;
}

https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/models/config.ts#L82

labs-scnm commented Feb 27, 2017

I got this error on an Docker build. I set the HOME env to the same directory as the project root. That's why the configPath and this.globalConfigFilePath() are the same and returned every time with null. 😒

const configPath = this.configFilePath(projectPath);
if (!configPath || configPath === this.globalConfigFilePath()) {
  return null;
}

https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/models/config.ts#L82

@simonstewart

This comment has been minimized.

Show comment
Hide comment
@simonstewart

simonstewart Feb 28, 2017

Seeing the same issue on Win10. All fine on macOS with same codebase.

simonstewart commented Feb 28, 2017

Seeing the same issue on Win10. All fine on macOS with same codebase.

@jdschmitt

This comment has been minimized.

Show comment
Hide comment
@jdschmitt

jdschmitt Feb 28, 2017

Since I'm working on a pretty new repo, I just recreated from scratch using Angular CLI this time and everything is working for me. ¯_(ツ)_/¯

jdschmitt commented Feb 28, 2017

Since I'm working on a pretty new repo, I just recreated from scratch using Angular CLI this time and everything is working for me. ¯_(ツ)_/¯

@simonstewart

This comment has been minimized.

Show comment
Hide comment
@simonstewart

simonstewart Feb 28, 2017

@jdschmitt nice! Owe you a beer/coffee when in South Africa.

simonstewart commented Feb 28, 2017

@jdschmitt nice! Owe you a beer/coffee when in South Africa.

@jdschmitt

This comment has been minimized.

Show comment
Hide comment
@jdschmitt

jdschmitt Feb 28, 2017

On my way! ✈️ 🍻

jdschmitt commented Feb 28, 2017

On my way! ✈️ 🍻

@RickStrahl

This comment has been minimized.

Show comment
Hide comment
@RickStrahl

RickStrahl Mar 1, 2017

Also running into this on Windows. For me build and serve work fine, but any ng generate commands fails with:

TypeError: Cannot read property 'apps' of null

New project created with ng new.

@angular/cli: 1.0.0-rc.0
node: 7.6.0
os: win32 x64
@angular/common: 2.0.0
@angular/compiler: 2.0.0
@angular/core: 2.0.0
@angular/forms: 2.0.0
@angular/http: 2.0.0
@angular/platform-browser: 2.0.0
@angular/platform-browser-dynamic: 2.0.0
@angular/platform-server: 2.0.0
@angular/router: 3.0.0
@angular/upgrade: 2.0.0
@angular/cli: 1.0.0-rc.0

RickStrahl commented Mar 1, 2017

Also running into this on Windows. For me build and serve work fine, but any ng generate commands fails with:

TypeError: Cannot read property 'apps' of null

New project created with ng new.

@angular/cli: 1.0.0-rc.0
node: 7.6.0
os: win32 x64
@angular/common: 2.0.0
@angular/compiler: 2.0.0
@angular/core: 2.0.0
@angular/forms: 2.0.0
@angular/http: 2.0.0
@angular/platform-browser: 2.0.0
@angular/platform-browser-dynamic: 2.0.0
@angular/platform-server: 2.0.0
@angular/router: 3.0.0
@angular/upgrade: 2.0.0
@angular/cli: 1.0.0-rc.0
@cgebe

This comment has been minimized.

Show comment
Hide comment
@cgebe

cgebe Mar 7, 2017

same issue for me, when trying to ng serve:


2017-03-07T16:30:34.549+01:00 [APP/PROC/WEB/0] [ERR] Cannot read property 'config' of null
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] at check_port_1.checkPort.then.port (/home/vcap/app/node_modules/@angular/cli/commands/serve.js:103:26)
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] at process._tickCallback (internal/process/next_tick.js:103:7)
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] TypeError: Cannot read property 'config' of null
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] at Class.run (/home/vcap/app/node_modules/@angular/cli/tasks/serve.js:22:63)

removing the '.' from .angular-cli.json didn't solve the problem.

versions:

"node": "7.6.0"
"npm": "4.1.2"
"@angular/cli": "1.0.0-rc.1"

cgebe commented Mar 7, 2017

same issue for me, when trying to ng serve:


2017-03-07T16:30:34.549+01:00 [APP/PROC/WEB/0] [ERR] Cannot read property 'config' of null
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] at check_port_1.checkPort.then.port (/home/vcap/app/node_modules/@angular/cli/commands/serve.js:103:26)
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] at process._tickCallback (internal/process/next_tick.js:103:7)
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] TypeError: Cannot read property 'config' of null
2017-03-07T16:30:34.550+01:00 [APP/PROC/WEB/0] [ERR] at Class.run (/home/vcap/app/node_modules/@angular/cli/tasks/serve.js:22:63)

removing the '.' from .angular-cli.json didn't solve the problem.

versions:

"node": "7.6.0"
"npm": "4.1.2"
"@angular/cli": "1.0.0-rc.1"
@OneMuppet

This comment has been minimized.

Show comment
Hide comment
@OneMuppet

OneMuppet Mar 7, 2017

I had the same issue but solved it by running, (ng init):
./node_modules/.bin/ng init

Then you will get questions regarding which files to overwrite and which to keep.

After that I could run, (ng build):
./node_modules/.bin/ng build
without any problems.

OneMuppet commented Mar 7, 2017

I had the same issue but solved it by running, (ng init):
./node_modules/.bin/ng init

Then you will get questions regarding which files to overwrite and which to keep.

After that I could run, (ng build):
./node_modules/.bin/ng build
without any problems.

@mouna92

This comment has been minimized.

Show comment
Hide comment
@mouna92

mouna92 Mar 8, 2017

Thank you so much @OneMuppet , it works very good, i had the same probl and i solved it :)

mouna92 commented Mar 8, 2017

Thank you so much @OneMuppet , it works very good, i had the same probl and i solved it :)

@filipesilva

This comment has been minimized.

Show comment
Hide comment
@filipesilva

filipesilva Mar 13, 2017

Member

Heya all, I believe this must be a problem on your cli configs. There must be some kind of outdated entry there, or maybe you're using an old version of the CLI.

Have a look at https://github.com/angular/angular-cli/wiki/stories-rc-update to see how to update your project.

If someone can provide me with a repro that I can follow to see this error, I can look at it further.

Member

filipesilva commented Mar 13, 2017

Heya all, I believe this must be a problem on your cli configs. There must be some kind of outdated entry there, or maybe you're using an old version of the CLI.

Have a look at https://github.com/angular/angular-cli/wiki/stories-rc-update to see how to update your project.

If someone can provide me with a repro that I can follow to see this error, I can look at it further.

@al-tr

This comment has been minimized.

Show comment
Hide comment
@al-tr

al-tr Mar 15, 2017

Those, who have this problem: try to wipe node_modules directory.
Helped me locally. Maybe some old and cached by the server dependencies caused this.
But not working when deploying to heroku:

...
2017-03-15T23:09:57.879827+00:00 app[web.1]: > ng serve
2017-03-15T23:09:57.879828+00:00 app[web.1]:
2017-03-15T23:09:59.951036+00:00 heroku[web.1]: Process exited with status 1
2017-03-15T23:09:59.950350+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-15T23:09:59.857740+00:00 app[web.1]: TypeError: Cannot read property 'config' of null
2017-03-15T23:09:59.857156+00:00 app[web.1]: Cannot read property 'config' of null
2017-03-15T23:09:59.857741+00:00 app[web.1]:     at Class.run (/app/node_modules/@angular/cli/tasks/serve.js:22:63)
2017-03-15T23:09:59.857743+00:00 app[web.1]:     at check_port_1.checkPort.then.port (/app/node_modules/@angular/cli/commands/serve.js:103:26)
2017-03-15T23:09:59.857743+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:103:7)
2017-03-15T23:09:59.873249+00:00 app[web.1]:
2017-03-15T23:09:59.880433+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-03-15T23:09:59.880633+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-15T23:09:59.880796+00:00 app[web.1]: npm ERR! node v7.6.0
2017-03-15T23:09:59.880936+00:00 app[web.1]: npm ERR! npm  v4.1.2
2017-03-15T23:09:59.881064+00:00 app[web.1]: npm ERR! code ELIFECYCLE
...

wiping cache doesn't help in this case

al-tr commented Mar 15, 2017

Those, who have this problem: try to wipe node_modules directory.
Helped me locally. Maybe some old and cached by the server dependencies caused this.
But not working when deploying to heroku:

...
2017-03-15T23:09:57.879827+00:00 app[web.1]: > ng serve
2017-03-15T23:09:57.879828+00:00 app[web.1]:
2017-03-15T23:09:59.951036+00:00 heroku[web.1]: Process exited with status 1
2017-03-15T23:09:59.950350+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-15T23:09:59.857740+00:00 app[web.1]: TypeError: Cannot read property 'config' of null
2017-03-15T23:09:59.857156+00:00 app[web.1]: Cannot read property 'config' of null
2017-03-15T23:09:59.857741+00:00 app[web.1]:     at Class.run (/app/node_modules/@angular/cli/tasks/serve.js:22:63)
2017-03-15T23:09:59.857743+00:00 app[web.1]:     at check_port_1.checkPort.then.port (/app/node_modules/@angular/cli/commands/serve.js:103:26)
2017-03-15T23:09:59.857743+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:103:7)
2017-03-15T23:09:59.873249+00:00 app[web.1]:
2017-03-15T23:09:59.880433+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-03-15T23:09:59.880633+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-15T23:09:59.880796+00:00 app[web.1]: npm ERR! node v7.6.0
2017-03-15T23:09:59.880936+00:00 app[web.1]: npm ERR! npm  v4.1.2
2017-03-15T23:09:59.881064+00:00 app[web.1]: npm ERR! code ELIFECYCLE
...

wiping cache doesn't help in this case

@Ludevik

This comment has been minimized.

Show comment
Hide comment
@Ludevik

Ludevik Mar 18, 2017

I have same problem when trying to build the app on bitbucket pipelines with docker image.

20:35:33.019 [QUIET] [system.out] 
20:35:33.019 [QUIET] [system.out] > frontend@0.0.0 build /opt/atlassian/pipelines/agent/build/frontend
20:35:33.019 [QUIET] [system.out] > ng build
20:35:33.019 [QUIET] [system.out] 
20:35:34.503 [ERROR] [system.err] Cannot read property 'config' of null
20:35:34.504 [ERROR] [system.err] TypeError: Cannot read property 'config' of null
20:35:34.504 [ERROR] [system.err]     at Class.run (/opt/atlassian/pipelines/agent/build/frontend/node_modules/@angular/cli/tasks/build.js:16:56)
20:35:34.504 [ERROR] [system.err]     at Class.run (/opt/atlassian/pipelines/agent/build/frontend/node_modules/@angular/cli/commands/build.js:143:26)
20:35:34.504 [ERROR] [system.err]     at Class.<anonymous> (/opt/atlassian/pipelines/agent/build/frontend/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
20:35:34.504 [ERROR] [system.err]     at process._tickCallback (internal/process/next_tick.js:103:7)
20:35:34.513 [ERROR] [system.err] 
20:35:34.518 [ERROR] [system.err] npm ERR! Linux 4.9.9-coreos-r1
20:35:34.518 [ERROR] [system.err] npm ERR! argv "/opt/atlassian/pipelines/agent/build/frontend/node/node-v7.6.0-linux-x64/bin/node" "/opt/atlassian/pipelines/agent/build/frontend/node_modules/npm/bin/npm-cli.js" "run" "build"
20:35:34.518 [ERROR] [system.err] npm ERR! node v7.6.0
20:35:34.518 [ERROR] [system.err] npm ERR! npm  v4.1.2
20:35:34.518 [ERROR] [system.err] npm ERR! code ELIFECYCLE
20:35:34.518 [ERROR] [system.err] npm ERR! frontend@0.0.0 

Works ok on Win 10 machine locally.

ng --version:

@angular/cli: 1.0.0-rc.0
node: 7.7.3
os: win32 x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/platform-server: 2.4.5
@angular/router: 3.4.5
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.5

Ludevik commented Mar 18, 2017

I have same problem when trying to build the app on bitbucket pipelines with docker image.

20:35:33.019 [QUIET] [system.out] 
20:35:33.019 [QUIET] [system.out] > frontend@0.0.0 build /opt/atlassian/pipelines/agent/build/frontend
20:35:33.019 [QUIET] [system.out] > ng build
20:35:33.019 [QUIET] [system.out] 
20:35:34.503 [ERROR] [system.err] Cannot read property 'config' of null
20:35:34.504 [ERROR] [system.err] TypeError: Cannot read property 'config' of null
20:35:34.504 [ERROR] [system.err]     at Class.run (/opt/atlassian/pipelines/agent/build/frontend/node_modules/@angular/cli/tasks/build.js:16:56)
20:35:34.504 [ERROR] [system.err]     at Class.run (/opt/atlassian/pipelines/agent/build/frontend/node_modules/@angular/cli/commands/build.js:143:26)
20:35:34.504 [ERROR] [system.err]     at Class.<anonymous> (/opt/atlassian/pipelines/agent/build/frontend/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
20:35:34.504 [ERROR] [system.err]     at process._tickCallback (internal/process/next_tick.js:103:7)
20:35:34.513 [ERROR] [system.err] 
20:35:34.518 [ERROR] [system.err] npm ERR! Linux 4.9.9-coreos-r1
20:35:34.518 [ERROR] [system.err] npm ERR! argv "/opt/atlassian/pipelines/agent/build/frontend/node/node-v7.6.0-linux-x64/bin/node" "/opt/atlassian/pipelines/agent/build/frontend/node_modules/npm/bin/npm-cli.js" "run" "build"
20:35:34.518 [ERROR] [system.err] npm ERR! node v7.6.0
20:35:34.518 [ERROR] [system.err] npm ERR! npm  v4.1.2
20:35:34.518 [ERROR] [system.err] npm ERR! code ELIFECYCLE
20:35:34.518 [ERROR] [system.err] npm ERR! frontend@0.0.0 

Works ok on Win 10 machine locally.

ng --version:

@angular/cli: 1.0.0-rc.0
node: 7.7.3
os: win32 x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/platform-server: 2.4.5
@angular/router: 3.4.5
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.5
@mezoistvan

This comment has been minimized.

Show comment
Hide comment
@mezoistvan

mezoistvan Mar 21, 2017

We had the same problem after updating to an RC version of cli from beta. We were running the project in an ubuntu docker image on a CI. Because .angular-cli.json is considered a hidden file in linux, it was not copied to the image originally. shopt -s dotglob before copying solved the issue.

mezoistvan commented Mar 21, 2017

We had the same problem after updating to an RC version of cli from beta. We were running the project in an ubuntu docker image on a CI. Because .angular-cli.json is considered a hidden file in linux, it was not copied to the image originally. shopt -s dotglob before copying solved the issue.

@Ludevik

This comment has been minimized.

Show comment
Hide comment
@Ludevik

Ludevik Mar 22, 2017

Thanks @mezoistvan for hint. Now it works on docker image too :)

Ludevik commented Mar 22, 2017

Thanks @mezoistvan for hint. Now it works on docker image too :)

@gtzinos

This comment has been minimized.

Show comment
Hide comment
@gtzinos

gtzinos Apr 22, 2017

Guys you maybe moved your files to another subdirectory.

gtzinos commented Apr 22, 2017

Guys you maybe moved your files to another subdirectory.

@HDaghash

This comment has been minimized.

Show comment
Hide comment
@HDaghash

HDaghash Apr 26, 2017

guys i found the solution ! :D
in my case i moved the project to another directory
there is a hidden file called .angular-cli
show the hidden file in the old project and copy this file and past it in the new distention .
this is solved the issue for me .

HDaghash commented Apr 26, 2017

guys i found the solution ! :D
in my case i moved the project to another directory
there is a hidden file called .angular-cli
show the hidden file in the old project and copy this file and past it in the new distention .
this is solved the issue for me .

@ishandutta2007

This comment has been minimized.

Show comment
Hide comment
@ishandutta2007

ishandutta2007 May 8, 2017

I have .angular-cli.json in the same directory but still sudo npm run build gives me this error

ishandutta2007 commented May 8, 2017

I have .angular-cli.json in the same directory but still sudo npm run build gives me this error

@lflores

This comment has been minimized.

Show comment
Hide comment
@lflores

lflores May 10, 2017

@HDaghash, it works for me!! thanks. In my case I have created it, with ng new, but I don't want another directory into root directory, then I have moved the generated code, to my project root, and I forgot mentioned file.

lflores commented May 10, 2017

@HDaghash, it works for me!! thanks. In my case I have created it, with ng new, but I don't want another directory into root directory, then I have moved the generated code, to my project root, and I forgot mentioned file.

@justfathi

This comment has been minimized.

Show comment
Hide comment
@justfathi

justfathi May 15, 2017

Guys, quickest solution is to do this
$ sudo rm -rf node_modules
$ npm install
$ ng serve

justfathi commented May 15, 2017

Guys, quickest solution is to do this
$ sudo rm -rf node_modules
$ npm install
$ ng serve

atereshkov added a commit to atereshkov/DiberWebClient that referenced this issue May 22, 2017

@pshisbey

This comment has been minimized.

Show comment
Hide comment
@pshisbey

pshisbey Jun 4, 2017

@HDaghash, Thanks! copying .angular-cli.json from an old project to the new worked!

pshisbey commented Jun 4, 2017

@HDaghash, Thanks! copying .angular-cli.json from an old project to the new worked!

@megamindbrian

This comment has been minimized.

Show comment
Hide comment
@megamindbrian

megamindbrian Jun 6, 2017

This is a really bad error message.

megamindbrian commented Jun 6, 2017

This is a really bad error message.

@luigitonno

This comment has been minimized.

Show comment
Hide comment
@luigitonno

luigitonno Jun 11, 2017

Copying the .angular-cli.json worked (fine)... But it could't be the plan that I have to copying this file when I create a new project...!

luigitonno commented Jun 11, 2017

Copying the .angular-cli.json worked (fine)... But it could't be the plan that I have to copying this file when I create a new project...!

@TimeIsGoOn

This comment has been minimized.

Show comment
Hide comment
@TimeIsGoOn

TimeIsGoOn Jul 13, 2017

you must have .angular-cli.json
it use my one day

TimeIsGoOn commented Jul 13, 2017

you must have .angular-cli.json
it use my one day

@brucepc

This comment has been minimized.

Show comment
Hide comment
@brucepc

brucepc Jul 31, 2017

Looks like an usage problem of almost of app(skeleton) generators....
I believe a simple option to set directory to create the app should solve this issue...
something like ng new app-name [dir-name]

brucepc commented Jul 31, 2017

Looks like an usage problem of almost of app(skeleton) generators....
I believe a simple option to set directory to create the app should solve this issue...
something like ng new app-name [dir-name]

@karocksjoelee

This comment has been minimized.

Show comment
Hide comment
@karocksjoelee

karocksjoelee Aug 15, 2017

If you are using MAC-OS , you can enter defaults write com.apple.finder AppleShowAllFiles TRUE;\killall Finder in your terminal for showing the hidden files .

karocksjoelee commented Aug 15, 2017

If you are using MAC-OS , you can enter defaults write com.apple.finder AppleShowAllFiles TRUE;\killall Finder in your terminal for showing the hidden files .

@yosiasz

This comment has been minimized.

Show comment
Hide comment
@yosiasz

yosiasz Aug 16, 2017

I already had an existing application I wanted to start using angular-cli in. When trying to implement angular-cli for an existing application, for me, just doing npm install -g @angular/cli and then trying to use the ng commands did not work.
After installing angular-cli I did the following.
In a command line, in windows, I went to my C:\ folder and ran the command
ng new foo. After nicely scaffolding my app, I copied the necessary files from this new folder and started moving them to my existing app folder and started sorting out the issues until I got my app running fine using angular-cli. This is the solution that worked for me when trying to implement angular-cli for an already existing application. Hope it helps

yosiasz commented Aug 16, 2017

I already had an existing application I wanted to start using angular-cli in. When trying to implement angular-cli for an existing application, for me, just doing npm install -g @angular/cli and then trying to use the ng commands did not work.
After installing angular-cli I did the following.
In a command line, in windows, I went to my C:\ folder and ran the command
ng new foo. After nicely scaffolding my app, I copied the necessary files from this new folder and started moving them to my existing app folder and started sorting out the issues until I got my app running fine using angular-cli. This is the solution that worked for me when trying to implement angular-cli for an already existing application. Hope it helps

@DeborahK DeborahK referenced this issue Sep 1, 2017

Closed

npm start error #55

@fmmajd

This comment has been minimized.

Show comment
Hide comment
@fmmajd

fmmajd Sep 19, 2017

it's happened to me several times. All of them, the problem was I had moved the project to different folders, and I did it through files/finder/explorer, so some hidden files weren't copied.
try removing the new project, and copying it with the command line. worked awesome for me.

fmmajd commented Sep 19, 2017

it's happened to me several times. All of them, the problem was I had moved the project to different folders, and I did it through files/finder/explorer, so some hidden files weren't copied.
try removing the new project, and copying it with the command line. worked awesome for me.

@artuska

This comment has been minimized.

Show comment
Hide comment
@artuska

artuska Sep 22, 2017

Well, did anyone in this thread mentioned it is because .angular-cli.json is a hidden file and it is lost when you move your project to another folder? Did anyone or it is just me first? ;)

artuska commented Sep 22, 2017

Well, did anyone in this thread mentioned it is because .angular-cli.json is a hidden file and it is lost when you move your project to another folder? Did anyone or it is just me first? ;)

@adilsonmenezes

This comment has been minimized.

Show comment
Hide comment
@adilsonmenezes

adilsonmenezes Oct 13, 2017

SOLUTION: Na pasta do projeto deve conter um arquivo chamado: .angular-cli.json

PS: Caso tenha sido trocado a pasta do projeto para outro local sem ser exibido os arquivos ocultos, este arquivo acaba por não ser copiado junto com o projeto, ocasionando o erro!

adilsonmenezes commented Oct 13, 2017

SOLUTION: Na pasta do projeto deve conter um arquivo chamado: .angular-cli.json

PS: Caso tenha sido trocado a pasta do projeto para outro local sem ser exibido os arquivos ocultos, este arquivo acaba por não ser copiado junto com o projeto, ocasionando o erro!

@felixivance

This comment has been minimized.

Show comment
Hide comment
@felixivance

felixivance Oct 16, 2017

i found the solution ! :D
in my case i moved the project to another directory
there is a hidden file called .angular-cli
show the hidden file in the old project and copy this file and paste it in the new distention .
this is solved the issue for me .

felixivance commented Oct 16, 2017

i found the solution ! :D
in my case i moved the project to another directory
there is a hidden file called .angular-cli
show the hidden file in the old project and copy this file and paste it in the new distention .
this is solved the issue for me .

@jzapantis

This comment has been minimized.

Show comment
Hide comment
@jzapantis

jzapantis Oct 26, 2017

These responses helped me identify the solution. I have an older version of angular, and I pulled teammates code and got this error.

In my project root I had _angular-cli.json - I changed it to .angular-cli.json and it worked!

jzapantis commented Oct 26, 2017

These responses helped me identify the solution. I have an older version of angular, and I pulled teammates code and got this error.

In my project root I had _angular-cli.json - I changed it to .angular-cli.json and it worked!

@nirmalk31

This comment has been minimized.

Show comment
Hide comment
@nirmalk31

nirmalk31 Oct 30, 2017

I had same problem with
@angular/cli: 1.0.0
node: 6.10.3
os: win32 x64

first i tried with command "ng init" and ng build. It didn't worked.
In my case I just restarted the "Visual Studio code" it worked.

nirmalk31 commented Oct 30, 2017

I had same problem with
@angular/cli: 1.0.0
node: 6.10.3
os: win32 x64

first i tried with command "ng init" and ng build. It didn't worked.
In my case I just restarted the "Visual Studio code" it worked.

@09abhishek

This comment has been minimized.

Show comment
Hide comment
@09abhishek

09abhishek Nov 4, 2017

@soodvarun @ardiadrianadri @bougnat12 @jdschmitt @dpalita

Guys first of all try to check whether the the given file is there or not in the below project specified path.
file name : .angular-cli.json
note :

  1. This .angular-cli.json file should must be there.
    It should be .angular-cli.json only,not like (_ angular-cli.json) or anything else.

Check the screenshot 👍

image

The reason why it is showing error is basically due to above two mentioned points :

image

I hope it may help you guys!! 👍 :-)

09abhishek commented Nov 4, 2017

@soodvarun @ardiadrianadri @bougnat12 @jdschmitt @dpalita

Guys first of all try to check whether the the given file is there or not in the below project specified path.
file name : .angular-cli.json
note :

  1. This .angular-cli.json file should must be there.
    It should be .angular-cli.json only,not like (_ angular-cli.json) or anything else.

Check the screenshot 👍

image

The reason why it is showing error is basically due to above two mentioned points :

image

I hope it may help you guys!! 👍 :-)

@django18

This comment has been minimized.

Show comment
Hide comment
@django18

django18 Dec 12, 2017

It was caused due to missing .angular-cli.json as I created my repo in Linux environment and then was trying to run it in the windows environment by cloning the repo.

django18 commented Dec 12, 2017

It was caused due to missing .angular-cli.json as I created my repo in Linux environment and then was trying to run it in the windows environment by cloning the repo.

@narendrasinghrathore

This comment has been minimized.

Show comment
Hide comment
@narendrasinghrathore

narendrasinghrathore Jan 1, 2018

Got same issue.
Cause of this error:
Copying project files from old directory to another directory, .angular-cli.json not copied.
Solved:
By copying .angular-cli.json file from old project directory to new one.
Project building successfully.

narendrasinghrathore commented Jan 1, 2018

Got same issue.
Cause of this error:
Copying project files from old directory to another directory, .angular-cli.json not copied.
Solved:
By copying .angular-cli.json file from old project directory to new one.
Project building successfully.

@Quentinb

This comment has been minimized.

Show comment
Hide comment
@Quentinb

Quentinb Jan 24, 2018

Got the same issue today.
macOS Sierra (10.12.6)
Node v9.4.0
ngCli 1.6.5

Pulled a 3 month old NG app from a repo.

Fix:
I created a new App using "ng new foo" and copied the .angular-cli.json file form the new project into the cloned existing one.

Quentinb commented Jan 24, 2018

Got the same issue today.
macOS Sierra (10.12.6)
Node v9.4.0
ngCli 1.6.5

Pulled a 3 month old NG app from a repo.

Fix:
I created a new App using "ng new foo" and copied the .angular-cli.json file form the new project into the cloned existing one.

@kryaksy

This comment has been minimized.

Show comment
Hide comment

kryaksy commented Jan 28, 2018

@humanborg

This comment has been minimized.

Show comment
Hide comment
@humanborg

humanborg Feb 11, 2018

Hit the same issue as @narendrasinghrathore @django18, due to missing .angular-cli.json (when copying on macosx finder these .abc files are not visible). Copying the file manually resolved this issue.

humanborg commented Feb 11, 2018

Hit the same issue as @narendrasinghrathore @django18, due to missing .angular-cli.json (when copying on macosx finder these .abc files are not visible). Copying the file manually resolved this issue.

@gatzkerob

This comment has been minimized.

Show comment
Hide comment
@gatzkerob

gatzkerob Feb 11, 2018

My solution was embarrassingly simple: First, make sure you are in the correct directory before trying to use "ng serve".

gatzkerob commented Feb 11, 2018

My solution was embarrassingly simple: First, make sure you are in the correct directory before trying to use "ng serve".

@srikanthps

This comment has been minimized.

Show comment
Hide comment
@srikanthps

srikanthps Feb 17, 2018

My solution is to delete my app folder and recreate using "ng new".

First time I created the app, the download of NPM modules was slow and I switched by networks - later I cancelled the ng new and re-ran it withouth cleaning the dirs. That caused the issue for me. So, deleting the app directory and re-creating the app solved my issue.

This was on Windows

srikanthps commented Feb 17, 2018

My solution is to delete my app folder and recreate using "ng new".

First time I created the app, the download of NPM modules was slow and I switched by networks - later I cancelled the ng new and re-ran it withouth cleaning the dirs. That caused the issue for me. So, deleting the app directory and re-creating the app solved my issue.

This was on Windows

@ahmedkamr

This comment has been minimized.

Show comment
Hide comment
@ahmedkamr

ahmedkamr Feb 19, 2018

in my case
there is a hidden file called .angular-cli.json
just remove . from it name to be angular-cli.json

ahmedkamr commented Feb 19, 2018

in my case
there is a hidden file called .angular-cli.json
just remove . from it name to be angular-cli.json

@jonahbron

This comment has been minimized.

Show comment
Hide comment
@jonahbron

jonahbron Feb 20, 2018

This happened to me because I renamed the project/repo/everything, but forgot to rename the project name in .angular-cli.json. After I fixed it there, it worked just fine.

jonahbron commented Feb 20, 2018

This happened to me because I renamed the project/repo/everything, but forgot to rename the project name in .angular-cli.json. After I fixed it there, it worked just fine.

@developerndm

This comment has been minimized.

Show comment
Hide comment
@developerndm

developerndm Feb 28, 2018

Happened to me uploading a repo from windows to an online drive.

Made a new app and copped over the missing files.

developerndm commented Feb 28, 2018

Happened to me uploading a repo from windows to an online drive.

Made a new app and copped over the missing files.

@PaloMiklo

This comment has been minimized.

Show comment
Hide comment
@PaloMiklo

PaloMiklo Mar 6, 2018

I had the same error when I tried to run ng test. The solution was easy. I was located in wrong directory. I had to cd one level deeper, where all my files were located.

PaloMiklo commented Mar 6, 2018

I had the same error when I tried to run ng test. The solution was easy. I was located in wrong directory. I had to cd one level deeper, where all my files were located.

@piyarulps

This comment has been minimized.

Show comment
Hide comment
@piyarulps

piyarulps Mar 19, 2018

hello guys,
I think this is the simple problem we are ignored:
in this case, when I moved the project one directory to another directory
there is some hidden file called like::::::".angular-cli ", ".editorconfig".
show the hidden file in the old project and copy this file and past it in the new distention.
this is solved the issue for me.
or any other angular project or create a new project then copy the hidden file and past it in the new destination

piyarulps commented Mar 19, 2018

hello guys,
I think this is the simple problem we are ignored:
in this case, when I moved the project one directory to another directory
there is some hidden file called like::::::".angular-cli ", ".editorconfig".
show the hidden file in the old project and copy this file and past it in the new distention.
this is solved the issue for me.
or any other angular project or create a new project then copy the hidden file and past it in the new destination

@anandbabud1987

This comment has been minimized.

Show comment
Hide comment
@anandbabud1987

anandbabud1987 Apr 10, 2018

Same here. I copied to a new directory using cp -r command where it did not copy .angular-cli.json file which is a hidden file. if your machine is unix/mac then run this command on your source folder to find the .angular-cli.json . after copying to the destination folder it worked like charm.
ls -ltr Acommand should show hidden files.

anandbabud1987 commented Apr 10, 2018

Same here. I copied to a new directory using cp -r command where it did not copy .angular-cli.json file which is a hidden file. if your machine is unix/mac then run this command on your source folder to find the .angular-cli.json . after copying to the destination folder it worked like charm.
ls -ltr Acommand should show hidden files.

@trungtruc1094

This comment has been minimized.

Show comment
Hide comment
@trungtruc1094

trungtruc1094 May 10, 2018

@anandbabud1987 Your solution worked for me. I really appreciate your way. Thanks a lot, mate

trungtruc1094 commented May 10, 2018

@anandbabud1987 Your solution worked for me. I really appreciate your way. Thanks a lot, mate

@montheryounis

This comment has been minimized.

Show comment
Hide comment
@montheryounis

montheryounis Jun 2, 2018

@HDaghash, Thanks! copying .angular-cli.json from an old project to the new worked perfect

montheryounis commented Jun 2, 2018

@HDaghash, Thanks! copying .angular-cli.json from an old project to the new worked perfect

@blinks32

This comment has been minimized.

Show comment
Hide comment
@blinks32

blinks32 Oct 13, 2018

if you have this

_angular-cli.json

rename it to this

.angular-cli.json

blinks32 commented Oct 13, 2018

if you have this

_angular-cli.json

rename it to this

.angular-cli.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment