August 20, 2019
In the latest Monthly Update, we told you about
create-strapi-app, the new supported way to generate an application with Strapi. Let's dig a bit deeper into this and explain why we modified the way an app is generated with Strapi.
A new package was developed to replace the step of installing Strapi globally. This new package is a simpler and lighter step to getting your projects started in a more streamlined and less complicated way. By installing Strapi with this new CLI, we avoid problems with added and unnecessary dependencies, and we also avoid issues with versioning across different projects.
Before, Strapi users had first to install Strapi globally, and then install and build the Strapi project itself. Basically, two separate steps:
Install Strapi globally using:
npm install strapi@beta -g strapi new my-project --quickstart
Now, Strapi users need one step and one command to install Strapi (even with no prior installations of Strapi):
yarn create strapi-app my-project --quickstart
Additional benefits include a much faster installation when compared to the installation of Strapi globally.
Many of you are developing multiple, Strapi based projects, at the same time. Managing versions in any project is often a tedious matter of careful attention to detail and the use of back-ups. With a fast-moving project like Strapi, it can be even more challenging to manage versions. Strapi has new updates and releases nearly every week and major upgrades as a result of regular community feedbacks.
You no longer have to worry about older projects breaking when you update Strapi. You can perform the migration steps at a time when it suits you.
For creating new projects, we now recommend using
npx. In brief, you can now use either of these commands to create a new Strapi project or app.
yarn create command:
yarn create strapi-app my-project
npx create command:
npx create-strapi-app my-project
There is no need to install Strapi globally, and we don’t recommend doing so. From now on, managing your projects with yarn or npx installs the latest and lightest version possible of Strapi. The benefits of this are real and tangible.
yarn. Creating a Strapi app with npx or yarn only installs the necessary files for a local project — not a global installation.
yarnto create a new project, these automatically install the latest Strapi version. If you use
strapi newyou install whatever version of Strapi is on your computer.
After installing Strapi with either
yarn, we now recommend you use yarn to execute the basic project management commands:
Note: If you don’t have
yarn installed on your system, the dependencies install with
npm and commands run using,
npm run [cmd].
Now when you use
npx to create projects, you want to stay consistent in how you install projects. Use
npx and then stay consistent with which command you use in the installation of additional packages.
The documentation explains each command when using yarn, npm, or with using Strapi installed globally. The documentation also explains all the available options for each command.
Now when you read the docs, you see how to force the use of
npm (rather than
yarn, if you prefer npm). You learn how to disable the starting of a quickstart app. Moreover, you see how to delete a globally installed version of Strapi (and therefore take advantage of the new
We hope you will enjoy this new approach to creating an application with Strapi. Let us know your thoughts in the comments below!