I have a Nuxt 3 application that uses socket.io-client. The app builds and runs fine during development with a vanilla nuxt build
process.
When I attempt to build and deploy to Firebase using the "firebase" preset for Nitro (NITRO_PRESET=firebase nuxt build
), however, the resulting package fails to install with this error:
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "socket.io-client/build/esm-debug" of package "socket.io-client/build/esm-debug@4.4.0": name can only contain URL-friendly characters.
I can see that this "socket.io-client/build/esm-debug" package is, in fact, referenced in the package.json that was generated and placed in .output/server/package.json
(even though it is not referenced anywhere in my own project). I get the same error message when I run npm install
locally in this directory.
It seems that this package is being injected by the build process for some reason, and the module name is making npm unhappy. Is there anything I can do to prevent this?
Using node 18, socket.io-client@4.6.1
Abbreviated output from build process:
> NITRO_PRESET=firebase npm run build
Nuxi 3.4.3
Nuxt 3.4.3 with Nitro 2.4.0
ℹ Building client...
ℹ vite v4.3.5 building for production...
ℹ vite v4.3.5 building SSR bundle for production...
ℹ Building Nitro Server (preset: firebase)
✔ Nitro server built
Σ Total size: 16.7 MB (3.87 MB gzip)
✔ You can deploy this build using npx firebase deploy