-
Notifications
You must be signed in to change notification settings - Fork 197
SPFx FAQ and troubleshooting guide
- Node.js and NPM compatiblity issues
- Failure to install prerequisites
- Failure to add additional SPFx tab
- Failed to scaffold
- Failed to import existing SPFx solution
- Failed to deploy
- Add web part using Yeoman SharePoint generator of mismatched version
Note: #5 - #7 applies to TTK v5.x with local/global SPFx package selection while #1 - #4 applies to TTK v4.x before the feature deliver.
The following table lists SharePoint Framework and compatible versions of common tools and libraries, according to the SharePoint Framework compatibility page:
SPFx | Node.js | NPM | TypeScript | React |
---|---|---|---|---|
1.14 | LTS v12, LTS v14 | v5, v6 | v3.9 | v16.13.1 |
1.15 | LTS v14, LTS v16 | v6, v7, v8 | v4.5 | v16.13.1 |
1.16 | LTS v16.13+ | v7, v8 | v4.5 | v17.0.1 |
1.17 | LTS v16.13+ | v7, v8 | v4.5 | v17.0.1 |
1.18 | LTS v16, LTS v18 | v7, v8, v9 | v4.5, v4.7 | v17.0.1 |
1.19 | LTS v18 | v9 | v4.5, v4.7 | v17.0.1 |
1.20 | LTS v18 | v9 | v4.5, v4.7 | v17.0.1 |
Teams Toolkit automatically checks Node.js and NPM versions for the latest SharePoint Framework it supports (SPFx v1.20.0 as of writing). You will encounter the following errors during scaffolding if Teams Toolkit detects unsupported Node.js or NPM versions:
Teams Toolkit also checks if NPM is installed.
Check your npm and Node.js version. The SharePoint Framework v1.20.0 is supported on the following Node.js versions:
- Node.js v18 LTS (aka: Hydrogen)
Corresponding npm version is v8 for SPFx v1.20.0. Please make sure you have the right version installed for both npm and Node.js.
For SPFx app, Teams Toolkit uses Yeoman Generator for scaffolding. This requires both Yeoman CLI and the correct SPFx generator version to be installed.
SPFx scaffolding could fail due to unsuccessful installation of above prerequisites:
As the default behavior, Teams Toolkit will try to install them locally under HOME/.fx
. Should the installation fail, we would revert to use your globally installed ones.
Go to Manage > Settings > Extension > Teams Toolkit > SPFx Prerequisite Check or run 'Preferences: Open User Settings'.
And uncheck these 2:
- Ensure Yeoman CLI is installed
- Ensure SPFx generator is installed
In the output message in VSC, you should see the versions for Yeoman CLI and SPFx generator that Teams Toolkit supports. In this example output message, you can see that they are 4.3.0
and 1.14.0
:
In the following, navigate to your applicable scenario:
Teams Toolkit will use them for scaffolding, there's no further action that needs to be taken now. You can now retry creating a new SPFx Teams app.
- Run this any place in a terminal:
npm install --global yo
- Install the SPFx generator version that Teams Toolkit supports, say
1.14
:
npm install @microsoft/generator-sharepoint@1.14 -g
Install the Yeoman CLI version that Teams Toolkit supports, say 4.3.0
:
npm install --global yo@4.3.0
Install the SPFx generator version that Teams Toolkit supports, say 1.14
:
npm install @microsoft/generator-sharepoint@1.14 -g
- If the global version is higher than the supported version
You can continue with your currently installed version but please note that some of the latest features might not be supported in Teams Toolkit.
- If the global version is lower than supported
Install the SPFx generator version that Teams Toolkit supports, say
1.14
:
npm install @microsoft/generator-sharepoint@1.14 -g
Multi-tab SPFx project is supported in Teams Toolkit. To add an additional SPFx tab, you can try "Add features" and select "SPFx tab". Behind the scenes, Yeoman Generator is executed according to the configuration file (.yo-rc.json) in the current solution.
If .yo-rc.json file doesn't exist in your SPFx project, adding SPFx tab will fail with the following error:
Please follow the instructions here to continue:
- If your project is created by Teams Toolkit lower than v3.7.0, please create SPFx project with latest Teams Toolkit and migrate your codes.
- If your project is downloaded from Todo-list-SPFx sample app, please add the following configuration file to
SPFx
subfolder in your project:
{
"@microsoft/generator-sharepoint": {
"plusBeta": false,
"isCreatingSolution": true,
"version": ${SPFx_versioin},
"libraryName": "todo-list-sp-fx",
"libraryId": "c314487b-f51c-474d-823e-a2c3ec82b1ff",
"environment": "spo",
"packageManager": "npm",
"solutionName": "todo-list-sp-fx",
"solutionShortDescription": "todo-list-sp-fx description",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "webpart",
"template": "react"
}
}
Note: Replace SPFx_version
with the SPFx version used in your project.
Project creation failed. A possible reason could be from Yeoman SharePoint Generator.
- Check SPFx development environment compatibility.
- Check Node version by running the following command
node --version
- Check NPM version by running the following command
npm --version
- Check whether the version of Node and NPM are compatibile with the latest SPFx according to SharePoint Framework compatibility page and upgrade Node or NPM if needed.
- Check Node version by running the following command
- Or you could try to set up global SPFx development environment by following Set up your SharePoint Framework development environment and choose to scaffold using the globally installed packages.
Failed to retrieve existing SPFx solution information. Please make sure your SPFx solution is valid.
-
Check your existing SPFx solution is valid with standard project folder structure.
-
Check your web part(s) is(are) located at
.\src\webparts
folder under your selected solution folder. -
Check your web part(s) manifest file is(are) located at
.\src\webparts\{webpartName}\{webpartName}WebPart.manifest.json
. -
Check your web part(s) manifest file has following properties:
id - The property will be used as
entityId
to constructstaticTabs
in Teams manifest file.preconfiguredEntries - The property (preconfiguredEntries[0].title.default) will be used as
name
to constructstaticTabs
in Teams manifest file.
-
-
Or you could try to migrate your SPFx solution manually following Integrate Teams Toolkit with an existing SPFx solution.
Failed to deploy due to lint errors in gulp bundle task. Example:
(×) Error: cli/runNpxCommand failed.
(×) Error: Script ('npx gulp bundle --ship --no-color') execution error: Warning - lint - src/webparts/helloworld/HelloworldWebPart.ts(95,32): error @typescript-eslint/no-explicit-any: Unexpected any. Specify a different type.
There's a known issue that deploy stage will fail even if there're only lint warnings in log detail. The root cause is that when there're lint errors in your SPFx project, gulp bundle --ship --no-color
command in deploy stage will fail with exit code 1, but they're printed as warning in log details. See related GitHub issue for more details.
You'll need to fix the lint errors or disable related lint rules to continue.
To add additional web part in an existing SPFx solution, it is recommended to keep the version of @microsoft/generator that will be use to add web part and the solution version consistent to avoid any further build errors.
- Set up global SPFx dev dependencies
- Check the version of your SPFx solution. You could find it from the value of "version" in
src/.yo-rc.json
. - Install Yeoman SharePoint generator of your solution version
Note: if you don't have Yeoman installed before, you also need to install Yeoman following Install Yeoman
npm install @microsoft/generator-sharepoint@{version} --global
- Use Teams Toolkit to add web part.
- Check the version of your SPFx solution. You could find it from the value of "version" in
- Or you could continue adding SPFx web part using current Sharepoint generator package and upgrade SPFx solution after the web part is added.
- Choose "continue" when prompting to confirm whether to add web part using package of mismatched version.
- After the web part is added, you could upgrade your SPFx solution.
- Install CLI for Microsoft 365 following CLI for Microsoft 365
- Upgrade the project to the new version.
- You could find the new version from the value of dependencies (for example: the version of @microsoft/sp-core-library)in
src/package.json
. - Run upgrade command.
You could learn more about this command from spfx project upgrade
m365 spfx project upgrade --toVersion {version} --output md > "upgrade-report.md"
- Follow the steps in the generated report to upgrade the project.
- You could find the new version from the value of dependencies (for example: the version of @microsoft/sp-core-library)in
Build Custom Engine Copilots
- Build a basic AI chatbot for Teams
- Build an AI agent chatbot for Teams
- Expand AI bot's knowledge with your content
Scenario-based Tutorials
- Send notifications to Teams
- Respond to chat commands in Teams
- Respond to card actions in Teams
- Embed a dashboard canvas in Teams
Extend your app across Microsoft 365
- Teams tabs in Microsoft 365 and Outlook
- Teams message extension for Outlook
- Add Outlook Add-in to a Teams app
App settings and Microsoft Entra Apps
- Manage Application settings with Teams Toolkit
- Manage Microsoft Entra Application Registration with Teams Toolkit
- Use an existing Microsoft Entra app
- Use a multi-tenant Microsoft Entra app
Configure multiple capabilities
- How to configure Tab capability within your Teams app
- How to configure Bot capability within your Teams app
- How to configure Message Extension capability within your Teams app
Add Authentication to your app
- How to add single sign on in Teams Toolkit for Visual Studio Code
- How to enable Single Sign-on in Teams Toolkit for Visual Studio
Connect to cloud resources
- How to integrate Azure Functions with your Teams app
- How to integrate Azure API Management
- Integrate with Azure SQL Database
- Integrate with Azure Key Vault
Deploy apps to production