question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find package '/usr/src/app/.output/server/node_modules/ufo

See original GitHub issue

Environment

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'
}
  1. As mentioned in https://github.com/nuxt/framework/discussions/4479, we need to remove .nuxt, package.lock.json, yarn.lock and node_modules. But I’m not confident on this solution since I have no control on Production & Staging project folder.
  2. 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:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
zernoniacommented, Apr 26, 2022

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.

image

1reaction
dungonfqcommented, Apr 26, 2022

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, my node_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.

pipeline {
    agent any
    environment { }
    stages {
        // stage("Build test") {
        //     parallel {
        //         stage('Test image') {
        //             steps{
        //                 script {
        //                     sh '''
        //                         docker build -t ${IMAGE_NAME}:test -f Dockerfile .
        //                     '''
        //                 }
        //             }
        //         }
        //     }
        // }

        // stage('Test') {
        //     steps {
        //         script {
        //             docker.image('${IMAGE_NAME}:test').inside() {
        //                 sh '''
        //                     npm install
        //                     npm run prepare
        //                     npm run test
        //                 '''
        //             }
        //         }
        //     }
        //     post {
        //         always {
        //             jiraSendBuildInfo site: 'roadsurfer.atlassian.net'
        //         }
        //     }
        // }

        stage("Build And Publish") {
            when {
                branch "main"
                //tag "*"
            }
            steps {
                withCredentials([[ ... ]]) {
                script {
                    sh '''
                        $(aws ecr get-login --no-include-email --region eu-central-1)
                        docker build -t ${IMAGE_NAME}:${GIT_SHORT} -f Dockerfile .
                        docker push ${IMAGE_NAME}:${GIT_SHORT}
                    '''
                }
            }
            }
        }

        stage("Staging Deploy") {
            when {
                branch "main"
            }
            steps {
                withCredentials([
                    string(credentialsId: 'CUSTACCOUNT_STAGING_GTM_ID', variable: 'STAGING_GTM_ID'),
                ]){ ... }
                office365ConnectorSend ( )

            }
            post { }
        }

        stage("Verify Prod Deploy") { ... }

        stage("Production Deploy") { ... }
    }

    post {
        always {
            sh '''
                docker rmi -f ${IMAGE_NAME}:test
                docker rmi -f ${IMAGE_NAME}:${GIT_SHORT}
            '''
            cleanWs()
        }
    }
}

In short, nuxt v3.0.0-rc.1 was upgraded successfully 🙌🏻

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found