Permission Denied for NPM Module added to Cloud Code

I’ve followed the instructions from @mark-piller here -

Locally, I created a project folder and installed pdf-parse

npm install pdf-parse@1.1.1 --save

I then uploaded those folders to the servercode/node_module folder -

I have a simple test endpoint -

My test code is throwing the error -

pdf-parse is not found: EACCES: permission denied, open '/opt/backendless/repo/eee25b20-17fa-97dd-ff29-ec45a5072a00/files/servercode/node_modules/pdf-parse/index.js

I granted all the permissions to all the new folders and am still getting the error.

What am I missing?

Thanks,
Tim

Hello @Tim_Jones,

This issue isn’t related to Backendless permissions — it’s about OS-level file permissions. It looks like the files you uploaded from your local machine have restricted access.

To fix this, run the following command on your local machine:

chmod -R 644 /path/to/node_modules/pdf-parse

This makes all files readable and writable by the owner and readable by everyone else.

Once done, re-upload the files — Backendless should then be able to access them without any issues.

Regards,
Stanislaw

I’m on Windows. I tried giving “everyone” permission and re-uploading the folders with no change to the behavior.

Can you see on the server if the permission are different on the pdf-parse folder?

Tim

Unfortunately we can’t check permissions on our side. You could do it by yourself before loading files

cmd.exe: icacls "C:\Users\YourName\Documents\file.txt"
powershell: Get-Acl "C:\path\to\file" | Format-List

Let us know, if everything is ok with permissions on your side, there is a chance that problem comes from somewhere else.

“Everyone” has read and execute on the files, which an LLM told me was the closest permissions to 644.

Are you sure permissions are maintained between a Windows system and your backend when a file is uploaded?

Tim

I uploaded the file by FTP to a server I have access to. The permissions are set to 644 there -

Tim

Looks like index.js in this library written by you?

if (isDebugMode) {

    let PDF_FILE = './test/data/05-versions-space.pdf';
    let dataBuffer = Fs.readFileSync(PDF_FILE);
    Pdf(dataBuffer).then(function(data) {
        Fs.writeFileSync(`${PDF_FILE}.txt`, data.text, {
            encoding: 'utf8',
            flag: 'w'
        });
        debugger;
    }).catch(function(err) {
        debugger;
    });

}

Pay attention to “./test/data/05-versions-space.pdf” - it’s relative path and it will be calculated not from place where file located, but from place where we run the process. Add more logs and debug, potentially we can’t find this file and this is why we catch error.

Hi @Dima,

I did not write any of the files; they came from installing the packages. To be honest, I don’t know what I’m doing. I am trying to follow @mark-piller’s instructions on using NPM modules.

That is how the code is in the package -

Tim

Hello Tim,

I managed to find a workaround for the permissions issue (tested on macOS) while we investigate this incident. For now, try adding the required modules to a ZIP archive and drag-and-drop it into the Backendless file system. Once uploaded, extract the files directly there.

Regards,
Alexander

That worked! Thank you.

Tim