1

I have build an SPFx web part named AutoRefresh which does not use a javascript framework, then i tried to run those commands:-

gulp clean 
gulp build 
gulp bundle --ship 
gulp package-solution --ship 

but i got those errors:-

C:\SPFX\src\webparts\autoRefresh>gulp clean
[17:17:12] Working directory changed to C:\SPFX
Build target: DEBUG
[17:17:14] Using gulpfile C:\SPFX\gulpfile.js
[17:17:14] Starting 'clean'...
[17:17:14] Starting gulp
[17:17:14] Starting subtask 'clean'...
[17:17:14] Finished subtask 'clean' after 30 ms
[17:17:14] Finished 'clean' after 37 ms
[17:17:15] ==================[ Finished ]==================
[17:17:15] Project auto-refresh version:0.0.1
[17:17:15] Build tools version:3.18.1
[17:17:15] Node version:v18.20.4
[17:17:15] Total duration:3.02 s

C:\SPFX\src\webparts\autoRefresh>gulp build
[17:17:16] Working directory changed to C:\SPFX
Build target: DEBUG
[17:17:18] Using gulpfile C:\SPFX\gulpfile.js
[17:17:18] Starting 'build'...
[17:17:18] Starting gulp
[17:17:18] Starting subtask 'pre-copy'...
[17:17:18] Finished subtask 'pre-copy' after 51 ms
[17:17:18] Starting subtask 'copy-static-assets'...
[17:17:18] Starting subtask 'sass'...
[17:17:18] Finished subtask 'sass' after 237 ms
[17:17:18] Starting subtask 'lint'...
[17:17:18] [lint] eslint version: 8.7.0
[17:17:18] Starting subtask 'tsc'...
[17:17:18] [tsc] typescript version: 4.7.4
[17:17:18] Finished subtask 'copy-static-assets' after 399 ms
[17:17:21] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(8,1): error TS6133: 'escape' is declared but its value is never read.
[17:17:21] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(10,1): error TS6133: 'styles' is declared but its value is never read.
[17:17:21] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(19,11): error TS6133: '_isDarkTheme' is declared but its value is never read.
[17:17:21] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(20,11): error TS6133: '_environmentMessage' is declared but its value is never read.
[17:17:21] Error - 'tsc' sub task errored after 2.67 s
exited with code 2
[17:17:21] 'build' errored after 3.09 s
About to exit with code: 1
Process terminated before summary could be written, possible error in async code not continuing!
Trying to exit with exit code 1

C:\SPFX\src\webparts\autoRefresh>gulp bundle --ship
[17:17:21] Working directory changed to C:\SPFX
Build target: SHIP
[17:17:24] Using gulpfile C:\SPFX\gulpfile.js
[17:17:24] Starting 'bundle'...
[17:17:24] Starting gulp
[17:17:24] Starting subtask 'pre-copy'...
[17:17:24] Finished subtask 'pre-copy' after 52 ms
[17:17:24] Starting subtask 'copy-static-assets'...
[17:17:24] Starting subtask 'sass'...
[17:17:24] Finished subtask 'sass' after 232 ms
[17:17:24] Starting subtask 'lint'...
[17:17:24] [lint] eslint version: 8.7.0
[17:17:24] Starting subtask 'tsc'...
[17:17:24] [tsc] typescript version: 4.7.4
[17:17:24] Finished subtask 'copy-static-assets' after 374 ms
[17:17:27] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(8,1): error TS6133: 'escape' is declared but its value is never read.
[17:17:27] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(10,1): error TS6133: 'styles' is declared but its value is never read.
[17:17:27] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(19,11): error TS6133: '_isDarkTheme' is declared but its value is never read.
[17:17:27] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(20,11): error TS6133: '_environmentMessage' is declared but its value is never read.
[17:17:27] Error - 'tsc' sub task errored after 2.63 s
exited with code 2
[17:17:27] 'bundle' errored after 3.03 s
About to exit with code: 1
Process terminated before summary could be written, possible error in async code not continuing!
Trying to exit with exit code 1

C:\SPFX\src\webparts\autoRefresh>gulp package-solution --ship
[17:17:27] Working directory changed to C:\SPFX
Build target: SHIP
[17:17:29] Using gulpfile C:\SPFX\gulpfile.js
[17:17:29] Starting 'package-solution'...
[17:17:29] Starting gulp
[17:17:29] Starting subtask 'package-solution'...
[17:17:29] Error - [package-solution] No manifests were found in 'C:\SPFX/release/manifests'. Ensure a build has completed successfully
[17:17:29] Finished subtask 'package-solution' after 17 ms
[17:17:29] Finished 'package-solution' after 23 ms
[17:17:30] ==================[ Finished ]==================
Error - [package-solution] No manifests were found in 'C:/SPFX/release/manifests'. Ensure a build has completed successfully
[17:17:31] Project auto-refresh version:0.0.1
[17:17:31] Build tools version:3.18.1
[17:17:31] Node version:v18.20.4
[17:17:31] Total duration:2.93 s
[17:17:31] Task errors:1
The build failed because a task wrote output to stderr.
Exiting with exit code: 1

any advice? Thanks

Also in my case the SPFx folder does not have a release sub-folder, as follow:-

enter image description here

5
  • 1
    Your console logs are having errors in "AutoRefreshWebPart.ts" file. Resolve them first, I guess after that solution should start working. Commented Aug 28 at 15:03
  • @DikeshGandhi Thaks for the reply. they are not really issues (from my c# skills), they are saying that some variables are not been read (defined but not read).. also should i run the gulp build inside the c:\SPFX ? or inside "c\SPFx\C:\SPFX\src\webparts\autoRefresh>"? Commented Aug 28 at 15:10
  • 1
    please comment out those lines in your ts file, and then run below commands at "c:\SPFX". first gulp bundle --ship and then gulp package-solution --ship. Commented Aug 28 at 15:15
  • 1
    @DikeshGandhi yes this worked well.. can you add your comment as a reply so i can accept it, for others to benefit from this. as for many developers from c# skills as in my case, having unused variables (is not best practice i agree), but will not cause an error at runtime Commented Aug 28 at 15:42
  • 1
    I'm glad that worked for you. You can accept Jleture's response. It has all the information. Commented Aug 29 at 7:08

1 Answer 1

2

The error is caused by non-used declared variables:

[17:17:21] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(8,1): error TS6133: 'escape' is declared but its value is never read.
[17:17:21] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(10,1): error TS6133: 'styles' is declared but its value is never read.
[17:17:21] Error - [tsc] src/webparts/autoRefresh/AutoRefreshWebPart.ts(19,11): error TS6133: '_isDarkTheme' is declared but its value is never read.

You have to edit the config file tsconfig.json at the root of your SPFx and add a new key "noUnusedLocals": false:

{
  "compilerOptions": {
    "noUnusedLocals": false
  }
}

Of course, you can also used the declared variable or delete it from the source code!

References:

3
  • 2
    one suggestion: editing tsconfig.json is not the best practice. Instead, we should have removed those unused variables from the code - it helps us in writing cleaner code. Commented Aug 28 at 15:24
  • 2
    Hah, I was just about to comment the same thing as @DikeshGandhi - it's probably a better practice to actually remove the unused variables entirely, so that the code is more readable and understandable in the future, rather than supress error messages that may result in you missing an actual issue in the future because the errors have been supressed. Commented Aug 28 at 15:26
  • 1
    Of course it’s better to use the declared variables!
    – jleture
    Commented Aug 28 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.