It's important to keep Directus up to date. Each new version fixes bugs or issues that have been discovered since the last one. Some even contain new features that enrich your data and your user experience. In this article I will cover how you can update Directus to version 10. This assumes you know how to access your Server and use the command line.
To update Directus, you must first navigate to your project folder. Once there, execute
npm install directus@10 command using the same user as the project folder's owner. Lastly, check for any Database schema changes using
npx directus database migrate:latest. Restart Directus for the changes to show.
Let's go into more detail.
If you haven't already, make sure to make a backup of your project before updating.
What's new in version 10?
If you are already on verion 9.26, not much is different. Version 10 adopts the new License model BSL 1.1 but is still completely free for most users. Check out the FAQ at Directus for more information.
If that's all that has changed, is it worth upgrading? The answer is yes. With no impact on our existing project, it's the perfect time to transition to v10. Furthermore, any subsequent updates will be covered by the standard updating procedures.
Step 1: Navigate to your Project Folder
Your Project folder is the folder where Directus is installed. Inside you should see the extensions folder, node_modules folder, uploads folder and a few files.
Using terminal or command prompt, change the current directory to your project folder.
LINUX cd /path/to/your/directus/project WINDOWS dir C:\path\to\your\directus\project
Step 2: Update Directus
By default just running the usual npm update will only upgrade to minor versions of the package. To install the next major version, we need to run the install command. The project will recognize that Directus is already installed and replace it with the specified version. This can also be used to downgrade Directus.
Run the following command:
LINUX sudo -u www npm install directus@10 WINDOWS npm install directus@10
After npm has completed installed Directus, it will output a report of any deprecation or security issues for the installed packages. Monospace strive to address these warnings and ensure Directus continues to be safe for everyone.
Step 3: Database Migrations
Whenever we update Directus, it's good practice to run any data migrations even when there are no changes. Use the follow command to run any migrations.
npx directus database migrate:latest
Step 4: Restart Directus
The final step is to restart Directus. This process will differ depend on how you installed Directus on the server. For example, if you have Directus installed as a service:
LINUX SERVICE sudo systemctl restart directus
In Windows, open the services window and find your Directus service. Right click, then click restart.
For anything else, open your process manager and restart the process. If in doubt, you can restart the whole server.
Step 5: Keep up to date
It's worth adding a reminder to your calendar at least once a month to check the Directus Github repo for any changes. Each new release will outline what has changed.
Now we know the importing difference between npm update and npm install when it comes to major version updates. With this knowledge, we can now upgrade to Directus v10 and keep the system up to date and secure. Be sure to check the github repo at least once a month for any changes.