Amplify build error - Cannot find module '/codebuild/output/....

0

Hi all

My vue app is running fine locally and builds fine locally, however, I'm trying to build my app on Amplify using a link to my github repo. The link and the clone work fine but I'm getting an error during the build.

Amplify push also works fine without problems.

I've only ever used NPM for all modules along with the vue-cli and Amplify-cli.

I have no idea where to start with this.

The main error seems to be : Cannot find module '/codebuild/output/src323788196/src/.yarn/releases/yarn-1.23.0-20210726.1745.cjs'

I've tried yarn install but that does not help. I'm not sure what to do next because I've never used yarn at all in this project.

My build config is standard -

version: 1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - npm install
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

The error I'm getting is -

[WARNING]: ✖ An error occurred when pushing the resources to the cloud
2022-01-04T06:47:49.986Z [WARNING]: ✖ There was an error initializing your environment.
2022-01-04T06:47:49.993Z [INFO]: Error: Packaging lambda function failed with the error 
[0mCommand failed with exit code 1: yarn --production
[0minternal/modules/cjs/loader.js:818
[0m  throw err;
[0m  ^
[0mError: Cannot find module '/codebuild/output/src323788196/src/.yarn/releases/yarn-1.23.0-20210726.1745.cjs'
[0m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
                                     at Function.Module._load (internal/modules/cjs/loader.js:667:27)
                                     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
                                     at internal/main/run_main_module.js:17:47 {
                                   code: 'MODULE_NOT_FOUND',
                                   requireStack: []
                                 }
                                     at runPackageManager (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/src/utils/legacyBuild.ts:66:13)
                                     at installDependencies (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/src/utils/legacyBuild.ts:40:3)
                                     at Object.buildResource [as build] (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-nodejs-function-runtime-provider/src/utils/legacyBuild.ts:13:5)
                                     at buildFunction (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-function/src/provider-utils/awscloudformation/utils/buildFunction.ts:41:36)
                                     at prepareResource (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:605:33)
                                     at async Promise.all (index 1)
                                     at prepareBuildableResources (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:601:10)
                                     at Object.run (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:173:5)
2022-01-04T06:47:50.024Z [ERROR]: !!! Build failed
2022-01-04T06:47:50.024Z [ERROR]: !!! Non-Zero Exit Code detected
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南