Cannot find package '/usr/src/app/.output/server/node_modules/ufo
See original GitHub issueEnvironment
Production & Staging
Reproduction
Cannot reproduce
Describe the bug
Im trying to upgrade "nuxt": "^3.0.0-rc.1"
in my application on Staging & Production. We use Docker + Jenkins to build & deploy. The application was built succesfully. But when I access the site, it loads infinitely and then stops the server.
Error log:
> fe-customer-account@1.0.0 start
> node .output/server/index.mjs
node:internal/process/esm_loader:94
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/usr/src/app/.output/server/node_modules/ufo/' imported from /usr/src/app/.output/server/index.mjs
Did you mean to import ufo/dist/index.cjs?
at new NodeError (node:internal/errors:371:5)
at legacyMainResolve (node:internal/modules/esm/resolve:336:9)
at packageResolve (node:internal/modules/esm/resolve:919:14)
at moduleResolve (node:internal/modules/esm/resolve:978:18)
at defaultResolve (node:internal/modules/esm/resolve:1080:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
at link (node:internal/modules/esm/module_job:78:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
- As mentioned in https://github.com/nuxt/framework/discussions/4479, we need to remove
.nuxt
,package.lock.json
,yarn.lock
andnode_modules
. But I’m not confident on this solution since I have no control on Production & Staging project folder. - Additionally, a possible cause can be from my server middleware. I’m using runtime config to create proxy middleware
import createProxy from '~/services/server/proxy'
const config = useRuntimeConfig()
const proxyMiddleware = createProxy(config.public.API_HOST)
/**
* @param {import('http').IncomingMessage} req
* @param {import('http').ServerResponse} res
* @param {Function} next
*/
export default async (req, res) => {
// Workaround for h3 not awaiting next.
await new Promise<void>((resolve, reject) => {
const next = (err?: unknown) => {
if (err) {
reject(err)
} else {
resolve()
}
}
// @ts-expect-error -- incompatible types express.Request and http.IncomingMessage. This still works though.
proxyMiddleware(req, res, next)
})
}
Do you guys have any idea about this missing module ufo
? I would like to try as many solutions as possible.
Additional context
Btw, I really happy Nuxt 3 was ready to release. My appreciation & big thanks to the team ❤️
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Go build: "Cannot find package" (even though GOPATH is set)
Even though I have GOPATH properly set, I still can't get "go build" or "go run" to find my own packages. What am...
Read more >Cannot find package "." in - nix-community/gomod2nix - GitHub
Describe the bug gomod2nix seems to struggle with go dependencies that are part of the repo and referenced by relative paths.
Read more >Cannot find package [SOLVED] - Getting Help - Go Forum
Hi! New with Go! My structure is: E: …GoWorkSpace …src …dp_project main.go controller.go …pkg …bin. The GOPATH is defined at: E:\GoWorkspace ...
Read more >Solved: Cannot find module react : npm install - YouTube
Cannot find module '@angular-devkit/build-angular/ package.json'. Stack Equation. Stack Equation. •. •. 25K views 1 year ago ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had similar error earlier. Turns out that my favicon wasn’t configured properly. I fix it by updating my
nuxt.config.ts
. Not sure if it provides any insight to your issue.Hi @danielroe @pi0 , thank you for supporting me on this issue.
I found the root cause in Jenkinsfile. Since I’m running both Test + Build & Deploy, the pipeline run
yarn install
multiple times. Therefore, mynode_modules
,.nuxt
,.output
was cached.Here is my Jenkinsfile, if I comment 2 first stages (Build test & Test) => my staging work well without any problem.
In short, nuxt
v3.0.0-rc.1
was upgraded successfully 🙌🏻