npx fast-serve config add throws error
SPFxAppDev opened this issue · 12 comments
Hi,
I am using SPFx 1.18.2 with the latest spfx-fast-serve package (and spfx-fast-serve-helpers v1.18). I also use Node 18 and pnpm as package manager.
When I run this command:
npx fast-serve config add
I get this error:
node:internal/modules/cjs/loader:1140
const err = new Error(message);
^
Error: Cannot find module 'D:\Projects\MyProj\news\fast-serve\config.json'
Require stack:
- D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\helpers.js
- D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js
- D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\devServer.js
- D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\serve.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.getJSONFile (D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\helpers.js:42:12)
at D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js:49:36
at Generator.next (<anonymous>)
at D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js:27:71
at new Promise (<anonymous>)
at __awaiter (D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js:23:12)
at createConfig (D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js:47:12)
at D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js:101:128
at Generator.next (<anonymous>)
at D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js:27:71
at new Promise (<anonymous>)
at __awaiter (D:\Projects\MyProj\news\node_modules\.pnpm\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\node_modules\spfx-fast-serve-helpers\lib\webpack\configureWebPack.js:23:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'D:\\Projects\\MyProj\\news\\node_modules\\.pnpm\\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\\node_modules\\spfx-fast-serve-helpers\\lib\\webpack\\helpers.js',
'D:\\Projects\\MyProj\\news\\node_modules\\.pnpm\\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\\node_modules\\spfx-fast-serve-helpers\\lib\\webpack\\configureWebPack.js',
'D:\\Projects\\MyProj\\news\\node_modules\\.pnpm\\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\\node_modules\\spfx-fast-serve-helpers\\lib\\webpack\\devServer.js',
'D:\\Projects\\MyProj\\news\\node_modules\\.pnpm\\spfx-fast-serve-helpers@1.18.0_@microsoft+load-themed-styles@2.0.116_eslint@8.7.0_typescript@4.7.4\\node_modules\\spfx-fast-serve-helpers\\lib\\serve.js'
]
}
Node.js v18.20.2
What am I doing wrong? The error confuses me a bit, because I think the command should create this file, but the error means that the file does not exist. Of course it is not there, because the command should create it :-D
Seems your \spfx-fast-serve-helpers
is not the latest, because in the stack trace it says spfx-fast-serve-helpers@1.18.0
, but should be 1.18.12
Hmmm, okay, I'll try, but the dependencies are installed automatically, right? I selected "yes/enter" when the spfx-fast-serve command asked me if I wanted to install the dependencies ....
(spfx-fast-serve Version 4.0.1)
EDIT:
After I manually updated the spfx-fast-serve-helpers package to version 1.18.12, it works
Hmmm, okay, I'll try, but the dependencies are installed automatically, right? I selected "yes/enter" when the spfx-fast-serve command asked me if I wanted to install the dependencies ....
Yep, as soon as you have tilde ~1.18.0
, the latest patch version should be installed, I've just tested with pnpm and it worked for me. Curious how 1.18.0 installed for you.
Yes, I know, the tilde installs the latest patch version. That's strange! I will keep an eye on this problem. Maybe it was just a "one in a million" case :D
I will close the issue, thanks for the quick help!
Hmmm, it's happening again with a new project. I don't know why. I use pnpm as package manager and it has installed version 1.18.0 again
If you have fast-serve listed in package.json with tilde, and if you remove pnpm's lock file and install dependencies, what version will be actually installed for you? (Assuming that you have ~1.18.0 in package.json)
Yes, it was ~1.18.0 ==> After I installed pnpm i spfx-fast-serve-helpers@latest
, it is now "spfx-fast-serve-helpers": "~1.18.12"
I deleted the pnpm-lock.yaml
and uninstalled the package spfx-fast-serve-helpers
and added "spfx-fast-serve-helpers": "~1.18.0"
in the package.json
again. Then I executed the pnpm i
command ==> Result: the version 1.18.0 was installed...
Which pnpm version do you use? Does it happen on windows, WSL, or OSX?
I use pnpm Version 8.6.5
with Node 16 on Windows
Strange enough, but when I tried with pnpm 8.6.5 I was able to reproduce the issue, but not with 8.15.7 (latest 8.x). For me, it looks like pnpm bug? Also works with pnpm 9.x.
Could you update pnpm and see if it resolves the issue?
This issue has been automatically closed because we haven't received any response back. Please feel free to reopen if needed.
Hi, sorry for the late reply. The PNPM update has solved the problem. Thank you