Skip to content

Commit bae0710

Browse files
waldekmastykarzVesaJuvonen
authored andcommitted
Updated the guidance on updating SharePoint Framework packages (#970)
1 parent b78c5c3 commit bae0710

File tree

1 file changed

+32
-45
lines changed

1 file changed

+32
-45
lines changed

docs/spfx/update-latest-packages.md

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ ms.prod: sharepoint
55
---
66

77

8-
# Update SharePoint Framework packages
8+
# Update SharePoint Framework packages
99

1010
SharePoint client-side development tools use the [npm](https://www.npmjs.com/) package manager to manage dependencies and other required JavaScript helpers. npm is typically included as part of Node.js setup.
1111

12-
When you create a new client-side solution, the yeoman generator for SharePoint fetches the latest SharePoint Framework packages required for your client-side project. As you build your project, your existing packages could be outdated as there could be new versions of one or more packages available. Based on the [release notes](https://aka.ms/spfx-release-notes) for a particular release or the latest package, you may decide to update your SharePoint Framework packages used in your project. SharePoint Framework packages include both the npm packages you have installed in your project, for example: [@microsoft/sp-core-library](https://www.npmjs.com/package/@microsoft/sp-core-library), and npm packages installed globally, for example: [@microsoft/generator-sharepoint](https://www.npmjs.com/package/@microsoft/generator-sharepoint).
12+
When you create a new client-side solution, the yeoman generator for SharePoint fetches the latest SharePoint Framework packages required for your client-side project. As you build your project, your existing packages could be outdated as there could be new versions of one or more packages available. Based on the [release notes](https://aka.ms/spfx-release-notes) for a particular release or the latest package, you may decide to update your SharePoint Framework packages used in your project. SharePoint Framework packages include both the npm packages you have installed in your project, for example: [@microsoft/sp-core-library](https://www.npmjs.com/package/@microsoft/sp-core-library), and npm packages installed globally, for example: [@microsoft/generator-sharepoint](https://www.npmjs.com/package/@microsoft/generator-sharepoint).
1313

14-
While it may not be required, it is recommended you update the SharePoint Framework packages every so often so that you can get the latest changes and fixes that have been released.
14+
While it may not be required, it is recommended you update the SharePoint Framework packages every so often so that you can get the latest changes and fixes that have been released.
1515

1616
## Find outdated packages in your project
17-
To find the outdated packages in your client-side project, including SharePoint Framework and other packages your project depends on, run the following command in a console in the same directory as your project.
1817

19-
```
18+
To find the outdated packages in your client-side project, including SharePoint Framework and other packages your project depends on, run the following command in a console in the same directory as your project.
19+
20+
```sh
2021
npm outdated
2122
```
2223

@@ -30,69 +31,61 @@ The command will list the following information about the packages your project
3031

3132
To identify the SharePoint Framework packages, look for the package names that start with the following npm scope and prefix:
3233

33-
```
34+
```sh
3435
@microsoft/sp-
3536
```
36-
Along with the framework packages, you may also need to update `react` and `office-ui-fabric-react` packages. Make sure you read the [release notes](https://aka.ms/spfx-release-notes) for that specific release to infer which packages require updates and plan accordingly.
3737

38-
### Update packages
39-
To update one or more packages to the latest version, you will need to edit the package(s) information in the `package.json` file and then fetch the latest packages.
40-
41-
#### Update package versions
42-
Open your project in your favorite code editor and locate the `package.json` file in the root of your project directory.
38+
Along with the framework packages, you may also need to update `react` and `office-ui-fabric-react` packages. Make sure you read the [release notes](https://aka.ms/spfx-release-notes) for that specific release to infer which packages require updates and plan accordingly.
4339

44-
In the `package.json` file, locate the package(s) under the `dependencies` and `devDependencies` section and update the version to the latest version available that was listed in the `npm outdated` command. For example, the image below highlights the version updates to SharePoint Framework packages, the left section referring to the old and the right section referring to the latest package versions.
40+
### Using npm outdated with project targeting SharePoint 2016
4541

46-
![Edit package versions in package.json file](../images/npm-update-packagejson-versions.png)
42+
Starting from Feature Pack 2, SharePoint 2016 supports SharePoint Framework solutions. SharePoint 2016 uses an older version of the SharePoint Framework, than the version available in SharePoint Online. When scaffolding new projects, the SharePoint Framework Yeoman generator prompts you to choose if your solution should be using the latest version of the SharePoint Framework and be working only with SharePoint Online or if it should use an older version of the SharePoint Framework and work with both SharePoint 2016 and SharePoint Online.
4743

48-
Once you have updated the package versions, Save the `package.json` file.
44+
When you run the `npm outdated` command in a project targeting both SharePoint Online and SharePoint 2016, it will show you the latest versions of the SharePoint Framework packages. These versions however work only with SharePoint Online. If you would update your solution to use these latest packages, it would not work with SharePoint 2016 anymore.
4945

50-
#### Update packages
51-
Open your favorite console and navigate to the root of your project directory. Follow the instructions below to successfully update the packages to its latest version.
46+
When working with SharePoint Framework solutions compatible with SharePoint hosted on-premises, you should always verify which patch level the target SharePoint farm has and which version of the SharePoint Framework it supports.
5247

53-
Delete the `node_modules` folder. This is the folder where npm installs the packages locally for your project. Deleting this folder forces npm to fetch the latest and not duplicate existing packages.
48+
### Update packages
5449

55-
If you are using a Mac or a Linux environment, then run the following command:
50+
When updating packages to newer versions, you should always use your package manager (npm or Yarn). You should not edit the `package.json` file manually. If you follow the recommended practice of using a lock file, your changes to the `package.json` file would be ignored.
5651

57-
```
58-
rm -rf node_modules/
59-
```
52+
Start with identifying which packages need updating and which newer version you want to use. Please note, that it might not always be possible for you to use the latest version of the given package as it might be incompatible with other SharePoint Framework dependencies, such as TypeScript.
6053

61-
If you are using a Windows environment, then run the following command:
54+
For each package that you want to update, run the following command:
6255

63-
```
64-
rd /s /q node_modules/
56+
```sh
57+
npm install mypackage@newversion --save
6558
```
6659

67-
Now, execute the following command to fetch the latest packages from the npm registry:
60+
For example, if you were using AngularJS version v1.5.9 and wanted to update to version 1.6.5, you would run:
6861

69-
```
70-
npm install
62+
```sh
63+
npm install [email protected] --save
7164
```
7265

73-
This command will create the `node_modules` folder and install all the packages your project depends on and its dependencies based on the information available in the `package.json` file. As we updated the file with the latest versions, npm will now have the latest packages and their dependencies installed.
66+
Updating the package using npm will install the specified version of the package in your project, update the version number in the package.json file dependencies and the lock file used in your project.
7467

7568
Once the packages are installed, execute the following command to clean up any old build artifacts:
7669

77-
```
70+
```sh
7871
gulp clean
7972
```
8073

8174
### Update your code
75+
8276
Depending on breaking API changes, you may have to update your existing project code and config files. For each release, the [release notes](https://aka.ms/spfx-release-notes) will highlight any such breaking changes and the modifications required to your existing code. You will need to make sure you update your code with those fixes.
8377

8478
You can always build the project to see if you have any errors and warnings by running the command in a console in your project directory:
8579

86-
```
80+
```sh
8781
gulp build
8882
```
8983

9084
## Update yeoman generator for SharePoint
91-
Unlike the npm packages that are installed to a specific client-side project, the yeoman generator for SharePoint is installed globally in your machine.
9285

93-
To find if the yeoman generator for SharePoint is out of date, run the following command in a console window.
86+
If you have installed the SharePoint Framework Yeoman generator globally, you can find out if it requires updating by running the following command:
9487

95-
```
88+
```sh
9689
npm outdated -g
9790
```
9891

@@ -106,26 +99,20 @@ The command will list the following information about the packages installed glo
10699

107100
To identify the generator package, look for the following package name:
108101

109-
```
102+
```sh
110103
@microsoft/generator-sharepoint
111104
```
112105

113106
### Update generator package
107+
114108
Open your favorite console and execute the following command to update the generator to its latest published version:
115109

116-
```
110+
```sh
117111
npm install @microsoft/generator-sharepoint@latest -g
118112
```
119113

120-
The command will update the yeoman generator for SharePoint to the latest published version along with its depedencies. You can validate this by executing the following command in the console:
114+
The command will update the yeoman generator for SharePoint to the latest published version along with its dependencies. You can validate this by executing the following command in the console:
121115

122-
```
116+
```sh
123117
npm ls @microsoft/generator-sharepoint -g --depth=0
124118
```
125-
126-
127-
128-
129-
130-
131-

0 commit comments

Comments
 (0)