question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating a project with existing directory => impossible?

See original GitHub issue

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:

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:open
  • Created 6 years ago
  • Reactions:36
  • Comments:33 (3 by maintainers)

github_iconTop GitHub Comments

16reactions
Krumpetcommented, Feb 18, 2018

I also encountered this problem: trying to create from within the project folder with --directory . failed with the error described above, as did cd ng new name --directory ./subdirectory

but this worked (without the dot): cd ng new name --directory subdirectory

15reactions
prigaracommented, Mar 5, 2018

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to add existing folder to project - MSDN - Microsoft
Hello,. I have a solution with 2 projects: The project AcsGE_Window has the folder AcsGE (this is a git submodule).
Read more >
How do I add an existing directory tree to a project in Visual ...
Right click in Windows explorer on the folder, and Copy on the folder with many files and folders. · Then in Visual Studio...
Read more >
Creating new project in existing directory no longer possible in ...
1. In the "Create New Project" dialog, I select a directory that already exists and contains a git repository with a readme. 2....
Read more >
Can't clone to existing directory, can't create project in existing ...
I then clone that to my Unreal Projects folder. Then, I launch Unreal Engine and create the new project with the same name...
Read more >
Unable to Load Rproj directories or create a New R project in ...
After the upgrade I am unable to open my existing R projects. Every time I open a .RProj file, it instead creates a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found