You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spfx/update-latest-packages.md
+32-45Lines changed: 32 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,19 @@ ms.prod: sharepoint
5
5
---
6
6
7
7
8
-
# Update SharePoint Framework packages
8
+
# Update SharePoint Framework packages
9
9
10
10
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.
11
11
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).
13
13
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.
15
15
16
16
## 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.
18
17
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
20
21
npm outdated
21
22
```
22
23
@@ -30,69 +31,61 @@ The command will list the following information about the packages your project
30
31
31
32
To identify the SharePoint Framework packages, look for the package names that start with the following npm scope and prefix:
32
33
33
-
```
34
+
```sh
34
35
@microsoft/sp-
35
36
```
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.
37
37
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.
43
39
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
45
41
46
-

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.
47
43
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.
49
45
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.
52
47
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
54
49
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.
56
51
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.
60
53
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:
62
55
63
-
```
64
-
rd /s /q node_modules/
56
+
```sh
57
+
npm install mypackage@newversion --save
65
58
```
66
59
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:
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.
74
67
75
68
Once the packages are installed, execute the following command to clean up any old build artifacts:
76
69
77
-
```
70
+
```sh
78
71
gulp clean
79
72
```
80
73
81
74
### Update your code
75
+
82
76
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.
83
77
84
78
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:
85
79
86
-
```
80
+
```sh
87
81
gulp build
88
82
```
89
83
90
84
## 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.
92
85
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:
94
87
95
-
```
88
+
```sh
96
89
npm outdated -g
97
90
```
98
91
@@ -106,26 +99,20 @@ The command will list the following information about the packages installed glo
106
99
107
100
To identify the generator package, look for the following package name:
108
101
109
-
```
102
+
```sh
110
103
@microsoft/generator-sharepoint
111
104
```
112
105
113
106
### Update generator package
107
+
114
108
Open your favorite console and execute the following command to update the generator to its latest published version:
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:
121
115
122
-
```
116
+
```sh
123
117
npm ls @microsoft/generator-sharepoint -g --depth=0
0 commit comments