Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add lambda function to my vue2 app using aws amplify cli #13374

Closed
3 tasks done
Johankoekoepan opened this issue Oct 27, 2023 · 10 comments
Closed
3 tasks done

Can't add lambda function to my vue2 app using aws amplify cli #13374

Johankoekoepan opened this issue Oct 27, 2023 · 10 comments
Labels
functions Issues tied to the functions category pending-response Issue is pending response from the issue author pending-triage Issue is pending triage transferred This issue was transferred from another Amplify project

Comments

@Johankoekoepan
Copy link

Johankoekoepan commented Oct 27, 2023

Before opening, please confirm:

JavaScript Framework

Vue

Amplify APIs

REST API

Amplify Categories

function

Environment information

# Put output below this line
$ npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages

  System:
    OS: Linux 6.2 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Memory: 8.57 GB / 15.55 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Browsers:
    Chrome: 117.0.5938.149
  npmPackages:
    @aws-amplify/ui-components: ^1.9.6 => 1.9.40 (1.9.6)
    @aws-amplify/ui-vue: ^1.0.11 => 1.1.20 
    @babel/core: ^7.12.16 => 7.20.12 
    @babel/eslint-parser: ^7.12.16 => 7.19.1 
    @vue/cli-plugin-babel: ~5.0.0 => 5.0.8 
    @vue/cli-plugin-eslint: ~5.0.0 => 5.0.8 
    @vue/cli-plugin-pwa: ~5.0.0 => 5.0.8 
    @vue/cli-service: ~5.0.0 => 5.0.8 
    @vue/compiler-sfc:  2.7.14 
    amplify-ui-components-loader:  undefined ()
    aws-amplify: ^4.3.21 => 4.3.46 
    aws-sdk: ^2.1185.0 => 2.1481.0 
    core-js: ^3.8.3 => 3.27.2 
    deepmerge: ^4.2.2 => 4.3.0 (1.5.2)
    dev:  1.0.0 
    eslint: ^7.32.0 => 7.32.0 
    eslint-plugin-vue: ^8.0.3 => 8.7.1 
    register-service-worker: ^1.7.2 => 1.7.2 
    sass: ~1.32.0 => 1.32.13 
    sass-loader: ^10.2.1 => 10.4.1 
    vue: ^2.6.14 => 2.7.14 
    vue-cli-plugin-vuetify: ~2.4.8 => 2.4.8 
    vue-cookie-law: ^1.13.3 => 1.13.3 
    vue-router: ^3.5.3 => 3.6.5 
    vue-template-compiler: ^2.6.14 => 2.7.14 
    vuetify: ^2.6.5 => 2.6.14 
    vuetify-loader: ^1.7.0 => 1.9.2 
    vuex: ^3.6.2 => 3.6.2 

Describe the bug

I tried adding a lambda function through the aws amplify cli but couldn't successfully push it to the cloud nor build it locally. I've tried looking at stackoverflow questions and github questions but I haven't found a solution that works for me. I tried doing 'npm i' in the src of my lambda function but that doesn't work either.

Expected behavior

It should push the lambda function to the cloud

Reproduction steps

Screenshot from 2023-10-27 16-29-39
Screenshot from 2023-10-27 16-33-38

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@Johankoekoepan Johankoekoepan added the pending-triage Issue is pending triage label Oct 27, 2023
@cwomack
Copy link
Member

cwomack commented Oct 27, 2023

Hello, @Johankoekoepan and thank you for opening this issue. To better assist, I'm going to transfer this issue to the amplify-cli repo.

@cwomack cwomack transferred this issue from aws-amplify/amplify-js Oct 27, 2023
@cwomack cwomack added the transferred This issue was transferred from another Amplify project label Oct 27, 2023
@josefaidt
Copy link
Contributor

Hey @Johankoekoepan 👋 thanks for raising this! As we begin to look at this in more depth I have a couple follow-up questions:

additionally, if you'd like to switch from yarn to npm you can delete the yarn.lock file in the function's src directory, install with npm to generate the package-lock.json, and push. Once the CLI detects the package-lock it will default to npm.

@josefaidt josefaidt added functions Issues tied to the functions category pending-response Issue is pending response from the issue author labels Oct 27, 2023
@Johankoekoepan
Copy link
Author

Johankoekoepan commented Oct 28, 2023

Hey man hope it's going well,

amplify --version shows 12.7.1
yarn --version shows 1.22.19
npm --version shows 10.2.1

But I use npm, and after i run npm install in the /src directory of my function and try to run amplify push again, it throws this error:

✔ Are you sure you want to continue? (Y/n) · yes
🛑 Packaging lambda function failed with the error
Command failed with exit code 243: npm install --no-bin-links --production

Screenshot from 2023-10-28 14-01-28
Screenshot from 2023-10-28 14-01-59

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 28, 2023
@josefaidt
Copy link
Contributor

Hey @Johankoekoepan thanks for clarifying! If you cd into this directory again and run the command printed in error npm install --no-bin-links --production does that also error? You should see a similar stack trace when running amplify commands with a --debug if so. Is there a postinstall step in your function's package.json that relies on a devDependency?

@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Oct 30, 2023
@Johankoekoepan
Copy link
Author

Hi @josefaidt, In the end I need a function with other dependencies in it yes, but that didn't work and so now I'm ONLY creating the function in the cli and trying to push it without any code modified in the function like app.js or package.json and it still wont let me push it. Running npm install --no-bin-links --production in the src of my lambda function it gives the exact same error again when I try to amplify push (I tried pushing twice, once after using the --production and the second push after using --omit=dev when running npm i in the src of the function):

Screenshot from 2023-10-31 10-17-54
Screenshot from 2023-10-31 10-18-29

Running amplify push with --debug I got the same error but more details about it:

Screenshot from 2023-10-31 10-32-35

✔ Are you sure you want to continue? (Y/n) · yes
🛑 Packaging lambda function failed with the error
Command failed with exit code 243: npm install --no-bin-links --production

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

PackagingLambdaFunctionError: Packaging lambda function failed with the error
Command failed with exit code 243: npm install --no-bin-links --production
at runPackageManager (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:100:19)
at runPackageManagerInstall (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:75:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async installDependencies (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:67:5)
at async Object.buildResource [as build] (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:44:13)
at async buildFunction (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-function/lib/provider-utils/awscloudformation/utils/buildFunction.js:29:22)
at async prepareResource (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:420:33)
at async prepareBuildableResources (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:416:5)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:177:5)
at async /snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:137:16
at async Promise.all (index 0)
at async providersPush (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:133:5)
at async AmplifyToolkit.pushResources (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:107:13)
at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:194:9)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)

Command failed with exit code 243: npm install --no-bin-links --production
Error: Command failed with exit code 243: npm install --no-bin-links --production
at makeError (/snapshot/amplify-cli/build/node_modules/execa/lib/error.js:60:11)
at Function.sync (/snapshot/amplify-cli/build/node_modules/execa/index.js:194:17)
at runPackageManager (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:87:25)
at runPackageManagerInstall (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:75:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async installDependencies (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:67:5)
at async Object.buildResource [as build] (/snapshot/amplify-cli/build/node_modules/amplify-nodejs-function-runtime-provider/lib/utils/legacyBuild.js:44:13)
at async buildFunction (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-category-function/lib/provider-utils/awscloudformation/utils/buildFunction.js:29:22)
at async prepareResource (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:420:33)
at async prepareBuildableResources (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:416:5)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:177:5)
at async /snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:137:16
at async Promise.all (index 0)
at async providersPush (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:133:5)
at async AmplifyToolkit.pushResources (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:107:13)
at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:194:9)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 31, 2023
@josefaidt
Copy link
Contributor

Hey @Johankoekoepan thanks for clarifying! The exit code being 243 is interesting. What version of Node.js are you using? Can you try deleting the associated node_modules directory and let the CLI attempt to install to a clean directory?

@josefaidt josefaidt added the pending-response Issue is pending response from the issue author label Oct 31, 2023
@Johankoekoepan
Copy link
Author

Hey @josefaidt , I've done an npm install with the node modules and package.lock deleted it still has the exact same behaviour when trying to push.

My node version is v18.18.0.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Nov 2, 2023
@ykethan
Copy link
Member

ykethan commented Dec 6, 2023

Following up on this issue, were you able to add the lambda function?

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Dec 6, 2023
@josefaidt
Copy link
Contributor

josefaidt commented Feb 2, 2024

Closing due to inactivity. @Johankoekoepan if you are still experiencing this issue please reply back to this thread or file a new report and we can investigate further

@josefaidt josefaidt closed this as not planned Won't fix, can't repro, duplicate, stale Feb 2, 2024
Copy link

github-actions bot commented Feb 2, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Issues tied to the functions category pending-response Issue is pending response from the issue author pending-triage Issue is pending triage transferred This issue was transferred from another Amplify project
Projects
None yet
Development

No branches or pull requests

4 participants