The current implementation of ng new does not allow creating a new project in an existing directory.
It would be interesting to have an option to generate the project in the current directory without removing everything.
This is already possible, try using this arguments:
ng new appName --directory ./
Closing as answered by @alvaro450, thanks!
This does not work.
I used exactly the command described above, result:
Error: Schematic input does not validate against the Schema: {"directory":"./","name":"appName","skipGit":false,"style":"css","version":"1.7.0","commit":{"message":"chore: initial commit from @angular/cli\n\n _ _ ____ _ ___\n / \\ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|\n / △ \\ | '_ \\ / _\\` | | | | |/ _\\` | '__| | | | | | |\n / ___ \\| | | | (_| | |_| | | (_| | | | |___| |___ | |\n/_/ \\_\\_| |_|\\__, |\\__,_|_|\\__,_|_| \\____|_____|___|\n |___/\n","name":"Angular CLI","email":"[email protected]"},"path":"app","sourceDir":"src","inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","skipTests":false,"skipInstall":false,"linkCli":false,"minimal":false,"serviceWorker":false}
Errors:
.directory should match format "path"
I am running angular-cli as a project dependency (i.e. not installed globally), in an existing node electron project.
I want to initialize the existing project as angular project, copying/adding the file structure to the existing project.
The command ng new appName --directory ./
does not work, as I get: You cannot use the new command inside an Angular CLI project.
My project does not have any angular-cli.json
file, but it has the angular-cli node_modules
folder and is listed as dependency in package.json
.
Since ng init
command is no longer available, is there a way of achieving what I want to do?
I'm using Node.js 7.9.0, npm 4.6.1, and the local angular-cli version is same as npm.
for me just ng new appName
did the trick
it generated inside existing directory
Angular CLI: 1.7.2 Node: 6.11.3 OS: win32 x64
I get the same error as @javlc, solution from @markopill didn't work either.
Angular CLI: 1.7.3, Ndoe: 8.1.3, OS: Windows 10 x64
ng new proj_name --directory ./
is not working for me as well producing the following error:
Error: Schematic input does not validate against the Schema: ...
Errors:
.directory should match format "path"
PS: not even working with absolute paths, it's trying to re-create entire directory structure inside project's folder.
Should be a bug, .directory should match format "path"
also showing for me.
Also, I made --directory ./
in the past and it worked before...
Work around i've found is to be one level higher then the directory you want.
Ex:
-develop (here)
-- project_folder (where you want to init angular)
so the command would be; ng new myAwesomeApp --directory project_folder
Additionally I get
```
error! project-name/README.md already exists.
error! project-name/.gitignore already exists.
````
If I'm trying to add this to a project where I have already put a lot of work into the gitignore/ README. Bummer.
@matthewwwillard it works for me, thanks!
ng new myAwesomeApp --directory project_folder
ng new appName --directory ./
is failing for Angular CLI: 6.0.1
Error message is:
Schematic input does not validate against the Schema: {"dryRun":false,"directory":".","version":"6.0.1","skipGit":false,"skipInstall":false,"linkCli":false,"commit":true,"newProjectRoot":"projects","inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","style":"css","skipTests":false}
Errors:
Data path ".directory" should match format "path".
Although, going back up one directory and doing this is fine: ng new appName --directory project_folder
Also: is there a reason why the --directory
flag is missing from ng new --help
?
It could save at least one Google search :)
Thanks @jericdeleon
It works for me. Thanks. 👍
@jericdeleon in Angular CLI 6 try to use --directory .
- works for me.
For folks having the same situation as @TylerGubala. Just backup those files and replace them after the project generation.
NOTE: Make sure the .gitignore file includes, at least, all of the generated .gitignore configuration.
ng new appName --directory ./ only works if its a fresh blank directory. Say i have an express app created already and i want to install and create a cli app , it won't allow as having a package.json already present there. Can this append to the package.json and help people out.
For now i did a workaround where renamed my existing package.json and copied things back.
I had the same problem about README.md file.
I run the ng new
command from the upper directory
cd ../
ng new my-project --directory './existing-folder'
Works like a charm.
I ended up just copying the files manually. Is there an issue created to get this added to the documentation and maybe even to all ./
?
@jericdeleon in Angular CLI 6 try to use
--directory .
- works for me.
Yes to create angular new project using cli in existing directory
ng new project_name --directory .
Tested in angular 7
Not working with @angular/cli 7.0.5.
ng new proj-name --directory .
creates a new directory proj-name in the current directory. Same as without the --directory flag.
ng new app_name --directory=./
works for me with below configuration.
Angular CLI: 7.3.4
Node: 10.15.0
OS: darwin x64
Angular: 7.2.7
Did not work for me until I updated Node after seeing the version posted by @Napster2210. --directory .
works after node --version
reports v11.11.0
.
cli 7.3.3 you can use ng new --directory .
for create in current directory
ng new --directory .
works with the configuration below:
Angular CLI: 8.1.3
Node: 10.15.3
OS: darwin x64
Angular: 8.1.3
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._
Most helpful comment
This is already possible, try using this arguments:
ng new appName --directory ./