Error on serve after create SPFx Extension - Cannot find module 'eslint/use-at-your-own-risk'
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
๐ฅ SharePoint Framework
Developer environment
Windows
What browser(s) / client(s) have you tested
- [ ] ๐ฅ Internet Explorer
- [ ] ๐ฅ Microsoft Edge
- [ ] ๐ฅ Google Chrome
- [ ] ๐ฅ FireFox
- [ ] ๐ฅ Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [X] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
- SPFx version: 1.17.1
- Node.js version: 16.14.2 (also tested with 16.20.0)
- npm version: 8.19.4
Describe the bug / error
Hello,
I want to create a new Application Customizer.
Just after creating an SPFx Application Customizer, I run the gulp serve command.
The following error is returned:
PS C:\dev\spfx> gulp serve
Build target: DEBUG
[18:46:01] Using gulpfile C:\dev\spfx\gulpfile.js
[18:46:01] Starting 'serve'...
[18:46:01] Starting gulp
[18:46:01] Starting subtask 'spfx-serve'...
[18:46:01] [spfx-serve] To load your scripts, use this query string: ?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.js
[18:46:01] Starting server...
[18:46:01] Finished subtask 'spfx-serve' after 179 ms
[18:46:01] Starting subtask 'pre-copy'...
[18:46:01] Finished subtask 'pre-copy' after 46 ms
[18:46:01] Starting subtask 'copy-static-assets'...
[18:46:01] Starting subtask 'sass'...
[18:46:01] Server started https://localhost:4321
[18:46:01] LiveReload started on port 35729
[18:46:01] Running server
[18:46:01] Opening https://{tenantdomain}/SitePages/myPage.aspx?debugManifestsFile=https%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js&loadSPFX=true&customActions=%7B%22c5dfa59e-c487-4eeb-8ab3-25adf894f9b7%22%3A%7B%22location%22%3A%22ClientSideExtension.ApplicationCustomizer%22%2C%22properties%22%3A%7B%22testMessage%22%3A%22Test+message%22%7D%7D%7D using the default OS app
[18:46:01] Finished subtask 'sass' after 29 ms
[18:46:01] Starting subtask 'lint'...
[18:46:01] [lint] eslint version: 8.7.0
[18:46:01] Starting subtask 'tsc'...
[18:46:01] [tsc] typescript version: 4.5.5
[18:46:02] Error - [lint] Unexpected STDERR output from ESLint: (node:3904) Warning: require() of ES modules is not supported.
require() of C:\dev\spfx\node_modules\@eslint\eslintrc\universal.js from C:\dev\spfx\node_modules\eslint\lib\linter\linter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename universal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\dev\spfx\node_modules\@eslint\eslintrc\package.json.
Oops! Something went wrong! :(
ESLint: 8.7.0
Error: Failed to load plugin '@typescript-eslint' declared in '.eslintrc.js ยป @microsoft/eslint-config-spfx/lib/profiles/default': Cannot find module 'eslint/use-at-your-own-risk'
Require stack:
- C:\dev\spfx\node_modules\@typescript-eslint\eslint-plugin\dist\util\getESLintCoreRule.js
- C:\dev\spfx\node_modules\@typescript-eslint\eslint-plugin\dist\rules\brace-style.js
- C:\dev\spfx\node_modules\@typescript-eslint\eslint-plugin\dist\rules\index.js
- C:\dev\spfx\node_modules\@typescript-eslint\eslint-plugin\dist\index.js
- C:\dev\spfx\node_modules\@eslint\eslintrc\dist\eslintrc.cjs
Referenced from: C:\dev\spfx\node_modules\@microsoft\eslint-config-spfx\lib\profiles\default.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (C:\dev\spfx\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at C:\dev\spfx\node_modules\@typescript-eslint\eslint-plugin\dist\util\getESLintCoreRule.js:34:5
at Object.<anonymous> (C:\dev\spfx\node_modules\@typescript-eslint\eslint-plugin\dist\rules\brace-style.js:5:60)
at Module._compile (C:\dev\spfx\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
[18:46:02] Error - [lint]
[18:46:02] Finished subtask 'lint' after 1.09 s
[18:46:02] Finished subtask 'copy-static-assets' after 1.15 s
[18:46:04] Finished subtask 'tsc' after 2.5 s
Steps to reproduce
- Create a new Application Customizer with SPFx 1.17.1
- Run gulp serve
- An eslint error is displayed
Expected behavior
No error with eslint
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Sorry for the massive delay here - we had an unfortunate dependency issue in early May, which should be now fully sorted out with those versions as well. Just tested with 1.17.1 without any issues. So this should be luckily sorted out. Please confirm if possible. Thx.
Thank you for the feedback @VesaJuvonen . I confirm that the issue can be closed now :)
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