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

🐛 Bug Report: Appwrite not installing modules in environment for CLI function deployment #6223

Closed
2 tasks done
DougieBoi227 opened this issue Sep 13, 2023 · 5 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@DougieBoi227
Copy link

DougieBoi227 commented Sep 13, 2023

👟 Reproduction steps

Create the basic template function

appwrite init function
? What would you like to name your function? My Awesome Function
? What ID would you like to have for your function? unique()
? What runtime would you like to use? Node.js (node-16.0)
✓ Success 

Deploy it

appwrite deploy function
? Which functions would you like to deploy? My Awesome Function (6501316f90f0917826da)
ℹ Info Deploying function My Awesome Function ( 6501316f90f0917826da )
ℹ Info Ignoring files using configuration from appwrite.json
✓ Success Deployed My Awesome Function ( 6501316f90f0917826da )
✓ Success Deployed 1 functions

Execute function from dashboard
Go to: Functions > My Awesome Function > Execute now > Execute (with default path="/" method="GET")

NOTE: I have tried creating a function with Node and Python and they both fail in similar ways. Python can't find the appwrite package like it wasn't pip installed.

👍 Expected behavior

Function return:
If envs are set
{areDevelopersAwesome: true}
If envs are not set
"Environment variables are not set. Function cannot use Appwrite SDK."

👎 Actual Behavior

STAUS FAILED:

Could not load code file.
Error: Cannot find module 'node-appwrite'
Require stack:

  • /usr/local/server/src/function/src/index.js
  • /usr/local/server/src/server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object. (/usr/local/server/src/function/src/index.js:1:13)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:101:39)

🎲 Appwrite version

1.4.x

💻 Operating system

Linux

🧱 Your Environment

CLI

appwrite -v
2.0.2

Appwrite version [1.4.2]

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@DougieBoi227 DougieBoi227 added the bug Something isn't working label Sep 13, 2023
@Inovvia
Copy link

Inovvia commented Sep 13, 2023

I also experienced this. As a work around I added commands here.
image

@DougieBoi227
Copy link
Author

Yep, that worked. Just a simple npm install added there was enough. Thanks!

@DougieBoi227
Copy link
Author

Unfortunately, that every time you redeploy from CLI that command gets removed. I'm guessing there's some confit with the appwrite.json config. Even when I explicitly add:

{
            "$id": "6501316f90f0917826da",
            "name": "My Awesome Function",
            "runtime": "node-16.0",
            "path": "functions/My Awesome Function",
            "entrypoint": "src/index.js",
            "ignore": [
                "node_modules",
                ".npm"
            ],
            "execute": [],
            "events": [],
            "schedule": "",
            "timeout": 15,
            "commands": "npm install"
}

It still goes away.

@stnguyen90
Copy link
Contributor

@DougieBoi227, would you please upgrade your Appwrite CLI? You should be using 4.0.0 with Appwrite 1.4

@stnguyen90 stnguyen90 self-assigned this Sep 13, 2023
@stnguyen90 stnguyen90 added the product / functions Fixes and upgrades for the Appwrite Functions. label Sep 13, 2023
@DougieBoi227
Copy link
Author

That was it. Upgrading fixed it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

3 participants