user1866924
user1866924

Reputation: 431

Ember.js - ember new command installing project in home directory instead of current directory

When I run the ember new command to create a new project, the project gets created in my home directory instead of the directory the new command is executed from.

Anyone know why?

Upvotes: 6

Views: 2142

Answers (2)

user1866924
user1866924

Reputation: 431

I had a package.json file in my root directory. Deleting it fixed the issue for me.

Upvotes: 7

Sid
Sid

Reputation: 2943

You have to use the ember init command if you want to create a new project in the current folder.

From the docs for init and new commands (http://www.ember-cli.com/#using-ember-cli):

ember new <project-name> description:

"Creates a folder called <project-name> and generates an application structure for you."

ember init description:

"Generates an application structure for you in the current folder."

Better descriptions can be found in the source code for the init and new commands (https://github.com/ember-cli/ember-cli/blob/18d377b264859548f41aba6c3ea2015b90978068/lib/commands/new.js and https://github.com/ember-cli/ember-cli/blob/18d377b264859548f41aba6c3ea2015b90978068/lib/commands/init.js):

ember new <project-name> description is:

"Creates a new folder and runs ember init in it."

The ember init description is:

"Creates a new ember-cli project in the current folder."

The relevant part of the ember new <project-name> code is:

return createAndStepIntoDirectory
  .run({
    directoryName: packageName,
    dryRun: commandOptions.dryRun
  })
  .then(initCommand.run.bind(initCommand, commandOptions, rawArgs))
  .then(gitInit.run.bind(gitInit, commandOptions, rawArgs));

So the new command creates and steps into the project directory name you pass into it and then runs init in that directory which generates all the ember goodness.

Note that the ember new <project-name> command also creates a git repository for you (if you have set up git on your machine) but the ember init command does not.

Upvotes: 13

Related Questions