Error compiling spfx framweork 1.8 react webpart with office ui fabric
Category
- [x] Question
- [ ] Typo
- [ ] Bug
- [ ] Additional article idea
Expected or Desired Behavior
I made a brand new Yeoman installation and I was able to create new react webpart (OOB).
Once when I tried to create webpart like specified here, I started to get build errors:
[14:53:43] [tslint] tslint version: 5.11.0 [14:53:43] Starting subtask 'tsc'... [14:53:43] [tsc] typescript version: 2.7.2 [14:53:45] Error - [tsc] node_modules/@uifabric/merge-styles/lib/IStyleSet.d.ts(15,67): error TS1005: ';' expected. [14:53:45] Error - [tsc] node_modules/@uifabric/merge-styles/lib/IStyleSet.d.ts(15,114): error TS1005: '(' expected. [14:53:45] Error - [tsc] node_modules/@uifabric/merge-styles/lib/IStyleSet.d.ts(15,136): error TS1005: '(' expected. [14:53:45] Error - 'tsc' sub task errored after 2.3 s
Any idea what could be the issue?
Thanks for your contribution! Sharing is caring.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
So, chances are there is a mismatch between the various components of TS, fabric react, and react. Can you paste your package.json here?
I'm seeing the same issue here. SPFx solution pretty bare bones. Posting my package:
{ "name": "project-status-review", "version": "0.0.1", "private": true, "engines": { "node": ">=0.10.0" }, "scripts": { "build": "gulp bundle", "clean": "gulp clean", "test": "gulp test" }, "dependencies": { "@microsoft/sp-core-library": "1.8.0", "@microsoft/sp-lodash-subset": "1.8.0", "@microsoft/sp-office-ui-fabric-core": "1.8.0", "@microsoft/sp-property-pane": "1.8.0", "@microsoft/sp-webpart-base": "1.8.0", "@pnp/common": "^1.3.0", "@pnp/logging": "^1.3.0", "@pnp/odata": "^1.3.0", "@pnp/sp": "^1.3.0", "@types/es6-promise": "0.0.33", "@types/react": "16.4.2", "@types/react-dom": "16.0.5", "@types/webpack-env": "1.13.1", "moment": "^2.24.0", "moment-business-days": "^1.1.3", "react": "16.7.0", "react-dom": "16.7.0" }, "resolutions": { "@types/react": "16.4.2" }, "devDependencies": { "@microsoft/sp-build-web": "1.8.0", "@microsoft/sp-tslint-rules": "1.8.0", "@microsoft/sp-module-interfaces": "1.8.0", "@microsoft/sp-webpart-workbench": "1.8.0", "@microsoft/rush-stack-compiler-2.7": "0.4.0", "gulp": "~3.9.1", "@types/chai": "3.4.34", "@types/mocha": "2.2.38", "ajv": "~5.2.2" } }
Ah. Bug in the docs. The problem is that OUIFR is being referenced, but there is no explicit reference in package.json, so it's picking up an incompatible ambient type.
Can you add "office-ui-fabric-react": "6.143.0" to the dependency section of your package.json file, rerun npm install, then rebuild?
That sounds like it'll work. However, to resolve it I actually just jumped up to the 3.3 TS and Compiler. That also did the trick in this case.
cool. thank you! I will close the question then
This sample is still not working for me. Added "office-ui-fabric-react": "6.143.0", to the package json. But sitll getting the same issue. Is there anything else that I need to configure.
That sounds like it'll work. However, to resolve it I actually just jumped up to the 3.3 TS and Compiler. That also did the trick in this case.
Moved to 3.3 TS and Compiler solved an issue for me as well!
To get around this issue i have updated my project to use TS 3.1 npm i @microsoft/rush-stack-compiler-3.1 --save-dev
then edit the top of your tsconfig.json so it is using 3.1
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.1/includes/tsconfig-web.json"
Elio's post explains more in detail. https://www.eliostruyf.com/define-the-typescript-version-you-want-to-use-in-sharepoint-framework/
That sounds like it'll work. However, to resolve it I actually just jumped up to the 3.3 TS and Compiler. That also did the trick in this case.
How did you do this?
@Paul-Colucci, the link that @spdavid posted above should help you get updated to 3.3.
Here it is again for quick reference. :)
https://www.eliostruyf.com/define-the-typescript-version-you-want-to-use-in-sharepoint-framework/
@Paul-Colucci, the link that @spdavid posted above should help you get updated to 3.3.
Here it is again for quick reference. :)
https://www.eliostruyf.com/define-the-typescript-version-you-want-to-use-in-sharepoint-framework/
Actually, I was just able to work it out. The problem is with the rush-stack-compiler-3.3 The only version that works is 0.1.6 so if you install the latest version it will fail. You also need to explicitly install typescript. To get it working i did the following:
Deleted node_modules and pacakge-lock.json run the following command: npm install @microsoft/[email protected] [email protected] --save-dev --save-exact update tsconfig.json to replace the extends variable with: "extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json", and finally run npm i
Hello, I am receiving the same build errors as mgordic, but I do not want to upgrade Typescript from 2.7. Is there anything else I can do to remove these errors?
@heliste2 - Yes. Explicitly add the version of fabric that you want to use in your package.json. In this case, make you sure have an entry for [email protected] and rerun npm install (or whatever package manager you are using)
Installing version 5.132.0 of office-ui-fabric-react worked to remove the errors, but now the property pane does not appear in the web part workbench. I am getting a console error of "***The value for "Custom field key" must not be undefined" in the sp-webpart-workbench-assembly file.
Missed your update. If you are having issues, might be worth opening up a new issue. For this one though, I ran through the tutorial, ran in both the local and hosted workbench, and didn't hit your issue. You might need to bring some more information (like the callstack of the message).
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues