Skip to content
Skip to content
Menu
A cup of dev
  • Home
  • About
  • Contact
  • Books and ink
A cup of dev

How to upgrade your SPfx project to the latest version, and how to fix/avoid common issues

By Eli H. Schei on Monday, 27 June 2022, 7:38Wednesday, 13 November 2024, 10:40

Recently I had to upgrade an older project to the newest version of SPfx, and even though there are some great tools to help you on your way you typically run into some errors anyway. In my search for solutions all I found was posts about upgrading older versions of SPfx. So I thought I should write a blogpost that covers upgrading to the newest per june 2022, which is SPfx 1.14.0

How to upgrade your project

You could try to just upgrade the SPfx packages that are listed in package.json. But these might have other dependencies that should also be updated and their packages might have dependencies… and so on.

So instead I reccomend that you use Microsoft 365 CLI to generate a report that tells you exactly what to upgrade.

1. Install Microsoft 365 CLI

npm i -g @pnp/cli-microsoft365

2. Use the project upgrade command to get a upgrade-report for your project

m365 spfx project upgrade --toVersion 1.14.0 --output md > "upgrade-report.md"

The above command will generate a markdown file with the name “upgrade-report”, and this will have a list of all the steps you need to take to upgrade your project.

Common errors and how to fix them (or avoid them)

Even though you follow the report you migh encounter some issues when trying to build your solution afterwards.

1. Check for duplicate dev-dependencies

Even though these are strictly speaking different npm packages you should only have on of them listed as a dependency or they might “get in each others way”. Check the upgrade report for wich version you should use. For me it was "...compiler-3.9": "0.4.47". So I removed the other one.

2. Delete node_modules, and package-lock.json

You can try npm dedupe before deleting node_modules and package-lock. This might solve any issues related to old versions – thanks to Waldek Mastykarz for mentioning this on twitter

To be sure there aren’t any old versions hanging around delete both your node_modules folder and the package-lock.json file and run npm install.

3. Deprecated tslint rules

You might need to remove some tslint rules that are no longer valid. The error message will tell you witch rule you need to remove. For me it was the member-access rule.

Error - [tslint] The 'member-access' rule threw an error ...

4. JavaScript heap out of memory

In my case, since this had something to do with tslint I think what probably solved it was removing the duplicate dependency as shown in the above section. But through my travels in google searches this showed up in multiple issues over differnt versions of SPfx – so I thought I should mention it.

If you have done the above steps and still gets this error it might be because the task needs more memory to run, so you can try fixing it by setting the --max_old_space_sice to a higher value.

 gulp bundle --max_old_space_size=8192 --ship

Summary

In short the steps you shuld take to upgrade your solution is

  • Run the M365 CLI project upgrade command
    • Do all the steps from the report that is generated
  • Check packacke.json for duplicate dev-dependencies
  • Try running npm dedupe
  • Delete node_modules and package-lock.json, and then run npm install.
  • If you get an error on deprecated tslint rules – delete the rules from the tslint file
  • If you get an JavaScript heap out of memory error – try adding more memory to the task with
    --max_old_space_size=8192

Have you encountered any other errors that should be mentioned? Let me know in the comments, or send me a tweet.


If you are interested in Microsoft 365 Development you might also like my other blogposts in this category.

Also, if you have any feedback or questions, please let me know in the comments below. ๐Ÿ™‚

Thank you for reading, and happy coding!

/Eli

If you want to support my content you can

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Post navigation

A comprehensive guide to Power Apps Component framework (PCF): Part 3 – Working with PCF components and Dataverse solutions
My top 5 uses for Microsoft 365 CLI

7 thoughts on “How to upgrade your SPfx project to the latest version, and how to fix/avoid common issues”

  1. Pingback: My top 5 uses for Microsoft 365 CLI - A cup of dev
  2. BK says:
    Thursday, 13 October 2022, 19:05 at 7:05 pm

    I am getting Error: Cannot find module ‘worker_threads’ error. None of the mentioned resolution on web seems to be working. Any suggestions.

    Loading...
    Reply
    1. Eli H. Schei says:
      Monday, 24 October 2022, 7:08 at 7:08 am

      It might have something to do with which node version you are running. If you are not using NVM allready I recommend reading this blogpost to see how you can use it to switch between node versions for different projects.

      Loading...
      Reply
      1. BK says:
        Thursday, 27 October 2022, 15:26 at 3:26 pm

        Thanks Eli. It was package-lock.json. once deleted, it compiles fine.

        Loading...
        Reply
        1. Eli H. Schei says:
          Friday, 28 October 2022, 6:39 at 6:39 am

          Glad you figured it out! And thanks for putting the solution in a comment here, maybe it will help someone else in the community that runs into the same issue. ๐Ÿ™‚

          Loading...
          Reply
  3. G says:
    Saturday, 3 February 2024, 19:08 at 7:08 pm

    Beautiful method! Thank you for sharing!

    Loading...
    Reply
  4. Prachi Agarwal says:
    Thursday, 5 December 2024, 13:20 at 1:20 pm

    I am getting issue when running gulp serve : Cannot find module ‘ajv/dist/core’

    Loading...
    Reply

Leave a ReplyCancel reply

Eli H. Schei

I'm a front-end developer who mainly work in the Microsoft 365-sphere. As a developer I read a lot of blogs. And in my experience I can read multiple different blogposts about exactly the same topic, and only one of them makes sense to me. Therefore Iโ€™m adding my voice to the mix, and hopefully one of my blogposts will be the one that makes sense of a topic for you. You can learn more about me here.

Recent Posts

  • How to create columns in Dataverse using PowerShell
  • React in ListViewCommandSet – how to fix the โ€œCannot read properties of undefined (reading โ€˜idโ€™)โ€ error
  • How to Get Site-ID with Graph Explorer (and other SharePoint info)
  • How to use Azure CLI to deploy Azure Functions: Step-by-Step Guide
  • Give your app granular permissions to a specific site or list in SharePoint

Categories

  • Azure
    • Azure CLI
    • Azure functions
  • Level
    • Beginner
    • Intermediate
  • Microsoft 365 Development
    • Microsoft Authentication Library
    • Microsoft Graph
    • Microsoft Teams
    • PNP powershell
    • SharePoint Framework
    • SharePoint Online
  • Power Platform
    • Dataverse
    • PowerApps
      • PowerApps Component Framework
  • Tech Lead
  • Web development
    • Accessibility
    • Soft skills
    • Tips and tricks

Tags

accessibility app permissions ARIA azure Azure CLI azure functions Content creation custom themes dataverse favorites git github ListViewCommandSet M365 CLI M365 development MS Graph PCF PnPjs PnP powershell power apps PowerApps Component Framework powershell quicktip react resources SharePoint Online Sideloading SPfx Teams teams app dev Teams apps Tech lead tools wcag webdev Windows terminal
©2025 A cup of dev | WordPress Theme by SuperbThemes.com
%d