Description
Versions
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:
- Adding angular-cli to existing project? On using ng init #755
- Provide a way to generate a new project in an existing directory #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"