|
| 1 | +# Scaffold projects using yeoman SharePoint generator |
| 2 | + |
| 3 | +[Yeoman](http://yeoman.io/) helps you to kickstart new projects, prescribing best practices and tools to help you stay productive. Using the yeoman SharePoint generator, developers are able to scaffold new client-side solution projects to build, package and deploy SharePoint solutions. The generator provides common build tools, boilerplate code, and a common playground web site to host web parts for testing. |
| 4 | + |
| 5 | +## Installing the yeoman SharePoint generator |
| 6 | + |
| 7 | +Yeoman SharePoint generator is available as part of the framework as a [npm package](https://www.npmjs.com/package/@microsoft/generator-sharepoint). You can install the generator by executing the following command in a console: |
| 8 | + |
| 9 | +``` |
| 10 | +npm install @microsoft/generator-sharepoint -g |
| 11 | +``` |
| 12 | + |
| 13 | +>**Note:** Yeoman generator for SharePoint is targeted to get deployed globally with the initial General Availability (GA) version. There are some known issues if it's installed locally to the project, which are planned to be addressed post GA. |
| 14 | +
|
| 15 | +It is recommended you follow the [set up your development environment](../spfx/set-up-your-development-environment.md) to configure your machine with the complete set of developer tools, including yeoman SharePoint generator. |
| 16 | + |
| 17 | +## Using the yeoman SharePoint generator |
| 18 | + |
| 19 | +Once the generator is installed, you can invoke the generator by just typing the following command in a console: |
| 20 | + |
| 21 | +``` |
| 22 | +yo |
| 23 | +``` |
| 24 | + |
| 25 | +The command will list all of the generators available in your machine. Select the `@microsoft/sharepoint` to invoke the SharePoint generator and continue with the prompts to successfully create your client-side solution: |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +## Available command line options for the generator |
| 30 | + |
| 31 | +You can use the command line options available with the yeoman SharePoint generator to scaffold projects in one command instead of going through the prompts. Execute the following command to see the list of command line options available for the SharePoint generator: |
| 32 | + |
| 33 | +``` |
| 34 | +yo @microsoft/generator-sharepoint --help |
| 35 | +``` |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +Option | Description |
| 40 | +-----|------ |
| 41 | +--skip-install|Do no automatically install dependencies. |
| 42 | +--solutionName|Client-side solution name, as well as folder name. |
| 43 | +--framework|Framework to use for the solution. Choose one from "none", "react", "knockout". |
| 44 | +--componentType|Component type. Currently only "webpart" is supported. |
| 45 | +--componentName|Name of the component. |
| 46 | +--componentDescription|Description of the component. |
| 47 | + |
| 48 | +Below is an example of a command that creates a solution called "hello-world" with a web part "HelloWorld" with "react" framework: |
| 49 | + |
| 50 | +``` |
| 51 | +yo @microsoft/sharepoint --solutionName "hello-world" --framework "react" --componentType "webpart" --componentName "HelloWorld" --componentDescription "HelloWorld web part" |
| 52 | +``` |
| 53 | + |
| 54 | +### Notes on --skip-install |
| 55 | + |
| 56 | +Using the `--skip-install` command will scaffold the project and skip installing dependencies. This means, to successfully build the project, you will need to install the dependencies later once the project is scaffolded. |
| 57 | + |
| 58 | +If you try to build your project without installing the dependencies, then you will get the following error. This indicates you need to install the dependencies before building the project: |
| 59 | + |
| 60 | +``` |
| 61 | +Local gulp not found in ~/<project-name> |
| 62 | +Try running: npm install gulp |
| 63 | +``` |
| 64 | + |
| 65 | +You can execute the following command to install the dependencies: |
| 66 | + |
| 67 | +``` |
| 68 | +npm install |
| 69 | +``` |
0 commit comments