Skip to content

Commit 4555386

Browse files
authored
Update SPFx dev guidance of SP19 & SPSE to support Node 16
1 parent df3731b commit 4555386

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

docs/spfx/sharepoint-2019-and-subscription-edition-support.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,26 @@ Microsoft recommends using the most recent version of the Yeoman generator for t
4949

5050
1. Install [Node.js v8.17.0](https://nodejs.org/download/release/v8.17.0/).
5151

52-
SPFx v1.4.1 is also supported on Node.js v12 and v14 (v12.18.1 and v14.17.1 to be specific), although there's an incompatible issue [gulp 3 wasn't compatible with Node 12+](https://github.com/gulpjs/gulp/issues/2324). The workaround to resolve this issue is to specify the version of graceful-fs component as 4+. You can create npm-shrinkwrap.json in the root folder of the project and input the following content, and then run “npm install”. Also, you can use package-lock.json to resolve this issue too.
53-
54-
```json
55-
{
56-
“dependencies”: {
57-
“graceful-fs”: {
58-
“version”: “4.2.2”
59-
}
60-
}
52+
SPFx v1.4.1 is also supported on Node.js v12, v14 and v16 (v12.18.1, v14.17.1 and v16.15.0 to be specific), though there're incompatible issues ([gulp v3 is incompatible with Node v12+](https://github.com/gulpjs/gulp/issues/2324), and node-sass v4 requires Node.js v14 or below). The workaround to resolve them is to specify the version of graceful-fs component as 4+, and to replace node-sass with sass. You can manually modify `package-lock.json` or `npm-shrinkwrap.json` and then re-run `npm install`. Or you can create a new `.js` file located in the root folder of your npm project, copy the following code into that file, run `node your_new_js_file` and re-run `npm install`.
53+
54+
```JavaScript
55+
const fs = require('fs');
56+
const lockedVersionFile = 'package-lock.json';
57+
// const lockedVersionFile = 'npm-shrinkwrap.json';
58+
const lockedVersionJson = JSON.parse(fs.readFileSync(lockedVersionFile));
59+
if (lockedVersionJson.packages) {
60+
const vinylFSJson = lockedVersionJson.packages["node_modules/vinyl-fs"];
61+
if (vinylFSJson && vinylFSJson["dependencies"] && vinylFSJson["dependencies"]["graceful-fs"]) {
62+
vinylFSJson["dependencies"]["graceful-fs"] = "npm:[email protected]";
63+
}
64+
65+
const gulpSassJson = lockedVersionJson.packages["node_modules/gulp-sass"];
66+
console.log(gulpSassJson);
67+
if (gulpSassJson && gulpSassJson["dependencies"] && gulpSassJson["dependencies"]["node-sass"]) {
68+
gulpSassJson["dependencies"]["node-sass"] = "npm:[email protected]";
69+
}
6170
}
71+
fs.writeFileSync(lockedVersionFile, JSON.stringify(lockedVersionJson, undefined, 2));
6272
```
6373

6474
1. Install global dependencies

0 commit comments

Comments
 (0)