Creating a project with existing directory => impossible?
See original GitHub issueVersions
ng --version: 1.7.0 npm --version: 5.0.3 node --version: v6.9.5 OS: Windows 10, 64-bit
Repro steps
- Create a new project folder:
$ mkdir test
- Switch into the folder:
$ cd test
- Install angular-cli:
$ npm install -g @angular/cli
- Try to create a new angular project with the currenct directory:
$ ng new appName --directory ./
The last step is nowhere officially documented, however, multiple GitHub-issues linked to this, including:
- https://github.com/angular/angular-cli/issues/755
- https://github.com/angular/angular-cli/issues/5431
In lack of a documented possibility to create an angular project in an existing directory, I used the above solution.
Observed behavior
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":"angular-cli@angular.io"},"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"
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":"angular-cli@angular.io"},"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"
(Yes, the command results in exactly above output - the error message is repeated twice)
Desired behavior
I would expect that angular generates files for a project in the folder, and of course no error message resulting. The files should be located directly in the “test”-folder and not be placed in a subfolder, e.g. “test/appName”.
Mention any other details that might be useful (optional)
Using an absolute path instead of a relatively one (in the ng new command) does not change anything, apart from the path-contents of the error message.
Using the command like $ ng new appName --directory .
(without the /
in the directory path) results in the same error.
Trying to reference the directory from itself by relative path (used as possible workaround) fails with a new error message:
$ mkdir test
$ cd test
$ ng new appName --directory "../test"
Error: Path "/../test" is invalid.
Path "/../test" is invalid.
If there is any other information I might help you with, please tell me.
Workaround
The same result can be achieved by changing into the parent directory and commanding angular to create the app in the sub-directory:
$ mkdir test
$ ng new appName --directory "test"
Issue Analytics
- State:
- Created 6 years ago
- Reactions:36
- Comments:33 (3 by maintainers)
I also encountered this problem: trying to create from within the project folder with
--directory .
failed with the error described above, as didcd
ng new name --directory ./subdirectory
but this worked (without the dot):
cd
ng new name --directory subdirectory
Hi @clydin, @Brocco, @hansl! As @denofevil has already mentioned in his comment, due to the path validation issue it is now impossible to create a new Angular project in WebStorm and other JetBrains IDEs using Angular CLI 1.7.0. The IDE creates a project directory first and only then runs angular-cli in it – that is something we can’t easily change. What can be done to solve the issue? We really hope that it would be possible again to create Angular projects in WebStorm. Thanks!