Angular-cli: ng init missing

Created on 2 Mar 2017  路  23Comments  路  Source: angular/angular-cli

OS : Windows 7

@angular/cli: 1.0.0-rc.0
node: 6.9.2
os: win32 x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8

I have a working angular project , I tried ng init, but it says init is missing

The specified command init is invalid. For available options, see `ng help`.

how do I CLIfy an existing project ?

thanks

Most helpful comment

dude, are you for real ? just read the bloody thread instead of blindly asking the same question I did 2 weeks ago

All 23 comments

The command was removed in a recent release.

https://github.com/angular/angular-cli/commit/a127cad

so i have to resttar a CLI project and put my code in it ?

Any solution for this?

For now yes. The init and update command were fairly consistently causing problems and so they were removed. In the RC the required updates will written out and done manually but the goal of the RC is to have no breaking changes. I have heard talk that there is work going into a proper update command.

so no solution for this right now....

The easiest way is to take a look at https://github.com/angular/angular-cli/blob/master/packages/%40angular/cli/blueprints/ng/files/package.json and comparing

or just ng new and copy that package.json

Closing this as fixed. You can also call ng new --src=. which may or may not overwrite some files. Use with caution, but it could get you started.

Nice, I ended up making the angular-cli.json file manually, unfortunately no easy to find documentation on the configuration file.

command ng new --src=. returns:

The option '--src' is not registered with the new command. Run ng new --help for a list of supported options.
The "ng new" command requires a name argument to be specified. For more details, use "ng help".

This causes issues for maven projects. When having to adhere to maven standards; developers should run their app from src/main/. The former ng init --sd=src/main/ui --style=scss --routing provided a solution for that. How can we escalate this issue and get the ng init back in the angular cli? Without it, I believe that we loose a very large audience.

@ Zurab-D ( ... on windows 7 , with grep installed )

ng --help | grep new
  Generates new code from blueprints.
ng new <options...>
  Creates a new directory and a new Angular app.

I thought maven was only used for java projects...

@phil123456: Some developers are required to bundle their angular applications with a back-end technology and generate a war file. This has been a standard practice in web development for a really long time. Not that I agree with it, a lot of developers find themselves working on these development stacks.

The ng new command wants to create a new directory. That's not the same thing as initializing angular in the root of an existing maven project and creating the source directory inside of src/main/ui. Also, if you don't have to grep installed; it's just as easy to ng new -h to achieve the same results. :)

@Zurab-D: is correct. ng new -src=. does not work and creates a folder in the root. I think @hansl was trying to say ng new -dir=. ; however, this still requires a name to be passed into the command.

So, following @hansl recommendation. We can run ng new appMavenAngularBundle -dir . -sd src/main/ui -si to build out the intended file structure.

I'm really not thrilled with this approach. When I run the command ng new without passing any flags, I get a new folder. Which implies that when I run the command ng new -* with flags it should rename or recreate the folder to the name I passed to the command. This is very confusing and implies risk.

@Brocco Could ng init just extend ng new in the next RC and build in directory where the command was executed? The ng new appMavenAngularBundle -dir . -sd src/main/ui -si works; however ng init appMavenAngularBundle -sd src/main/ui implies what it actually does. Also, it makes it easier for developers to infer the command's outcome. Just a thought! :)

@justinhorton3 that's exactly what it did do, but it was causing more problems than it solved. Removing it for now is the right decision. We are planning on implementing a more robust solution to upgrading/updating applications.

@Brocco Thanks for the quick response! I'm just glad that its on the road map for future releases!

When I am creating a new project I am getting the follwoing and nothing created. Installed/Reinstalled angular2-eclipse and no changes.
\Ang2Prj>ng init
The specified command init is invalid. For available options, see ng help.

dude, are you for real ? just read the bloody thread instead of blindly asking the same question I did 2 weeks ago

I used ng new my-app command and it works fine

"ng init" is one of awesome solution to create a project from blank git repository, but, from now, we must create a project first, then init git later. so sad!

Alternative way to "init your existing project" is simply:

1) Install "angular-cli" thru npm
2) add "angular-cli.json" file to the root folder (same folder, where package.json is) and past there content from some existing cli project (you might need to edit it to be appropriate)

@hieutranagi47 To create an angular project from an existing blank git repository, just run "ng new [your-git-name]" in the parent folder. It will generate the files inside the existing folder and skip git init. All fine after that...

For me npm install worked!

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._

Was this page helpful?
0 / 5 - 0 ratings