中文 (Chinese)English

1
Prerequisites

Before you begin, make sure you have Node.js 0.10+ and MongoDB v2.4+ installed.

You'll need a reasonable working knowledge of Javascript to use KeystoneJS, as well as familiarity with basics such as database concepts, and using node / npm etc.

2
Commands

Install the generator

You'll be using the KeystoneJS generator made with Yeoman. In your root directory run:

npm install -g generator-keystone

Create a folder for your project

Create your project wherever you want:

mkdir my-test-project

Than make sure you're in your new project:

cd my-test-project

Run the generator

yo keystone

The generator will ask you a few questions about what features you'd like to include, then configure and copy all the files you'll need into your project.

It will also install dependencies from npm so you're ready to go.

3
You're Done!

So you just created your first KeystoneJS project, congrats!

Run it in your command line like this:

node keystone

Then open http://localhost:3000 to view it in your browser.

If you want to see what the generator actually did take a look at our getting started guide, it'll walk you through the manual setup process. This is particularly helpful if you're new to Node.js.

View the getting started guide →

?
Problems

Something went wrong? Hopefully these tips will help.

ERR! Please try running this command again as root/Administrator.

When running npm install -g generator-keystone, you may get an EACCES error asking you to run the command again as root/Administrator. This indicates that there is a permissions issue.

On your development system you can change directory ownership to the current $USER so you do not have to run sudo while installing untrusted code:

sudo chown -R $USER /usr/local
 
# Other directories may be required depending on your O/S
sudo chown -R $USER /usr/lib/node_modules/

For a production/shared environment you may wish to re-run the npm command with the sudo prefix:

sudo npm install -g generator-keystone

For more information, see the "What, no sudo?" of the Intro to npm by Isaac Schulueter.

What do you mean it couldn't find my Database?

By default, KeystoneJS will look for a MongoDB server running on localhost on the default port, and connect to it. If you're getting errors related to the MongoDB connection, make sure your MongoDB server is running.

If you haven't installed MongoDB yet, follow the instructions below.

To connect to a server other than localhost, add a MONGO_URI setting to the .env file in your Keystone project directory:

MONGO_URI=mongodb://your-server/database-name

Something else?

If your issue still isn't resolved, reach out to us on the KeystoneJS Google Group.