14

I am new in Angular. I accidentally ejected my project using command-line, i don't remember which command i used. but when i try to run command

ng serve --open

it throws me an error of

An ejected project cannot use the build command anymore.

I also re-installed angular-cli as said in this Stackoverflow Question but no use.

Can anyone help me with this?

Community
  • 1
  • 1
Shweta
  • 1,212
  • 4
  • 20
  • 36

2 Answers2

44

open the angular-cli.json, you should see this at the top

"project": {
   "name": "proj-name",
   "ejected": true,
}

remove the ejected part and it should work

Saurabh Agrawal
  • 7,581
  • 2
  • 27
  • 51
phacic
  • 1,402
  • 1
  • 14
  • 21
  • 1
    The file is a hidden file in Ubuntu/UNIX. So, you have to open ".angular-cli.json" – Guru Apr 22 '17 at 00:59
  • Any why this is happened. Any configuration over written. – M2012 Sep 22 '17 at 13:19
  • I ejected mine because I wanted to use a different optimizer. I don't want to un-eject. Any idea how I can build with an ejected webpack.config? – abyrne85 Aug 10 '18 at 14:28
0

once you ejected the project you will get a webpack.config file

And also you can see some commands in package.json script tag

"scripts": {
"ng": "ng",
"start": "webpack-dev-server --port=4200",
"build": "webpack",
"test": "karma start ./karma.conf.js",
"lint": "ng lint",
"e2e": "protractor ./protractor.conf.js",
"pree2e": "webdriver-manager update --standalone false --gecko false --quiet"

},

you can still run the project by using npm start

you can still build the project by using npm run build

Lijo
  • 6,498
  • 5
  • 49
  • 60
  • when running 'npm start' - Getting error as- module.js:557 throw err; ^ Error: Cannot find module '@ngtools/webpack' – Mahi Jul 18 '18 at 08:17