Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 288
user1866924 Avatar asked Apr 03 '15 14:04

user1866924


2 Answers

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.

like image 63
Sid Avatar answered Nov 03 '22 20:11

Sid


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

like image 35
user1866924 Avatar answered Nov 03 '22 21:11

user1866924