Skip to content

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

@DougieBoi227

Description

@DougieBoi227

👟 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?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingproduct / functionsFixes and upgrades for the Appwrite Functions.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions