nocmt / ewelink-api-next

CoolKit v2 API Official Library
MIT License
19 stars 4 forks source link

AWS Lambda: ENOENT: no such file or directory, mkdir '/var/task/cache' #14

Closed AndrazPustotnik closed 10 months ago

AndrazPustotnik commented 10 months ago

I am getting ENOENT: no such file or directory, mkdir '/var/task/cache' response when trying to import ewelink-api-next into the aws lambda. It appears that node-localstorage is trying to write into read-only directory. Is it possible to navigate that into the /tmp which might fix the issue?

Full error:

{
    "errorType": "Error",
    "errorMessage": "ENOENT: no such file or directory, mkdir '/var/task/cache'",
    "code": "ENOENT",
    "errno": -2,
    "syscall": "mkdir",
    "path": "/var/task/cache",
    "stack": [
        "Error: ENOENT: no such file or directory, mkdir '/var/task/cache'",
        "    at Object.mkdirSync (node:fs:1398:3)",
        "    at v.v._init (/var/task/node_modules/node-localstorage/LocalStorage.js:183:14)",
        "    at v (/var/task/node_modules/node-localstorage/LocalStorage.js:124:12)",
        "    at Object.<anonymous> (/var/task/node_modules/ewelink-api-next/dist/index.mjs:3:20)",
        "    at Module._compile (node:internal/modules/cjs/loader:1256:14)",
        "    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)",
        "    at Module.load (node:internal/modules/cjs/loader:1119:32)",
        "    at Module._load (node:internal/modules/cjs/loader:960:12)",
        "    at Module.require (node:internal/modules/cjs/loader:1143:19)",
        "    at require (node:internal/modules/cjs/helpers:119:18)"
    ]
}
ghost commented 10 months ago

Expected to remove the reference to storage in V1.0.4, and the latest submission in the warehouse is ready for use. You can copy the four files in dist to the node of your project_ Select Overwrite in the "node_modules/ewelink-api-next/dist" directory and then you can use it.

AndrazPustotnik commented 10 months ago

For the time being I created a fork and replaced cache with /tmp like const localStorage = new LocalStorage("/tmp"); and it works. So if I understood correct after update there will be no writing into the cache so I will have no longer an issue with the storage?

ghost commented 10 months ago

For the time being I created a fork and replaced cache with /tmp like const localStorage = new LocalStorage("/tmp"); and it works. So if I understood correct after update there will be no writing into the cache so I will have no longer an issue with the storage?

Well, you can also do this