"npm outdated" showing my @microsoft/sp- packages being badly outdated.

How to update SharePoint Framework for an SPFx webpart?

This post was most recently updated on August 31st, 2022.

5 min read.

Instead of being stuck on whatever version your SPFx project was originally created with, it’s possible and sometimes required to upgrade it afterward to gain access to newer functionalities like integration with Microsoft Teams. This process, to me, is comparable to updating the .NET Framework version in your classic web application projects – while it’s sometimes a matter of simple configuration change and a rebuild, most of the time there are a bunch of steps included, and not all of them might be obvious or anywhere close to trivial to resolve. You might even have to dive deep into a dependency hell to figure out how to get all packages in compatible versions.

However, the tooling is there, and there are plenty of community resources to help you get going – and I’m trying to explain the typical steps in this article so that I don’t have to google them the next time I’m on a case like this again :)

Steps required to update your SPFx version in your webpart

Like always, I could be missing something. I’m just a guy documenting and sharing my solutions. If you find inconsistencies or have other comments, don’t hesitate to add them in the comments section below. Thanks!

On to the steps, then.

Time needed: 30 minutes

  • Verify that your devDependencies are up-to-date

    If after installing any of these packages you get a listing of dependencies that says “invalid”, like below, you need to verify your devDependencies are up-to-date with the other dependencies.

    In my case, I had forgotten to update the devDependencies. That would’ve bitten me in the butt later as well, so it was lucky to get the error at this point already. I didn’t mind fixing it when it’s this obvious.

    So, in short: if you have packages both as dependencies and devDependencies, make sure that the versions are the same.

    In my packages.json -file, I had different versions of some packages for "dependencies" and "devDependencies". This causes errors during npm install and will cause confusion down the line.In my packages.json -file, I had different versions of some packages for “dependencies” and “devDependencies”. This causes errors during the npm install and will cause confusion down the line.

    Good stuff.

  • Boot your stuff and get coding

    Now you’re ready to close down your Visual Studio Code and reopen it again.

    Et voíla!

    At this point, you should be ready to start coding. Whatever fancy new features you’re hoping to use, should be available.

    Wait, no, actually – I’ve got a ton of issues when building my code!

    Welp, that’s a thing that happens sometimes. Check out the next step

  • Additional tooling

    To figure out which build errors you might get, and what to do to get around them, you can run Office 365 CLI’s “spfx project upgrade” command – it’ll give you an analysis of the steps you’ll need to take.

    The command looks like the below:

    <pre lang=”powershell”>o365 spfx project upgrade –output md > report.md</pre>

    Hugo Bernier and Walked Mastykarz already have great articles on how to use this tool, so I’m not going into details here. See their posts here:



  • References

    Some sources for this blog article and other further reading are below: