samvera / serverless-iiif

IIIF Image API 2.1 & 3.0 server in an AWS Serverless Application
https://samvera.github.io/serverless-iiif/
Apache License 2.0
71 stars 23 forks source link

Error: Cannot find module 'iiif-processor' #72

Closed ryantomaselli closed 2 years ago

ryantomaselli commented 2 years ago

Hey guys;

I'm getting the following error when calling the cloudfront end point.

Error: Cannot find module 'iiif-processor'

I ran npm install at the root folder before running the following command in sam/cloudfront.

sam deploy --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND --guided

Any idea what might be the cause?

Thanks for any pointers.

mbklein commented 2 years ago

There are package.json files in the root, in src, and in dependencies. They all need to be installed.

ryantomaselli commented 2 years ago

There are package.json files in the root, in src, and in dependencies. They all need to be installed.

Ah, that makes sense. Thanks @mbklein

ryantomaselli commented 2 years ago

Hey @mbklein...

So I ran npm install in the root, src and dependencies...

Ran the deploy command sam deploy --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND --guided

But when I try to access the cloudfront end point I get the following error:

{
    "errorType": "Error",
    "errorMessage": "\nSomething went wrong installing the \"sharp\" module\n\nCannot find module '../build/Release/sharp-linux-x64.node'\nRequire stack:\n- /var/task/node_modules/sharp/lib/sharp.js\n- /var/task/node_modules/sharp/lib/constructor.js\n- /var/task/node_modules/sharp/lib/index.js\n- /var/task/node_modules/iiif-processor/lib/transform.js\n- /var/task/node_modules/iiif-processor/index.js\n- /var/task/index.js\n- /var/runtime/index.mjs\n\nPossible solutions:\n- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"\n- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install",
    "stack": [
        "Error: ",
        "Something went wrong installing the \"sharp\" module",
        "",
        "Cannot find module '../build/Release/sharp-linux-x64.node'",
        "Require stack:",
        "- /var/task/node_modules/sharp/lib/sharp.js",
        "- /var/task/node_modules/sharp/lib/constructor.js",
        "- /var/task/node_modules/sharp/lib/index.js",
        "- /var/task/node_modules/iiif-processor/lib/transform.js",
        "- /var/task/node_modules/iiif-processor/index.js",
        "- /var/task/index.js",
        "- /var/runtime/index.mjs",
        "",
        "Possible solutions:",
        "- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"",
        "- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"",
        "- Consult the installation documentation: https://sharp.pixelplumbing.com/install",
        "    at Object.<anonymous> (/var/task/node_modules/sharp/lib/sharp.js:31:9)",
        "    at Module._compile (node:internal/modules/cjs/loader:1105:14)",
        "    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)",
        "    at Module.load (node:internal/modules/cjs/loader:981:32)",
        "    at Function.Module._load (node:internal/modules/cjs/loader:822:12)",
        "    at Module.require (node:internal/modules/cjs/loader:1005:19)",
        "    at require (node:internal/modules/cjs/helpers:102:18)",
        "    at Object.<anonymous> (/var/task/node_modules/sharp/lib/constructor.js:8:1)",
        "    at Module._compile (node:internal/modules/cjs/loader:1105:14)",
        "    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)"
    ]
}

I must be close but no cigar yet...any idea why those libraries would not be available to the runtime?

ryantomaselli commented 2 years ago

One side note is that when I look at the Lambda function for a deployment using the AWS Serverless Application Repository the package size is a mere 181.1 kB whereas the deploy using the command line is 19.1 MB.

Because the package size is so large the AWS console Lambda editor won't display it to me, making it hard to verify what actual packages are being made available.

ryantomaselli commented 2 years ago

Just realized I'm not running the following command: sam build --use-container

Maybe that will do it.