Why am i getting this error while deploying backend?

==> Running ‘npm start’

Feb 17 02:23:31 PM

Feb 17 02:23:31 PM> backend@1.0.0 start

Feb 17 02:23:31 PM> node app.js

Feb 17 02:23:31 PM

Feb 17 02:23:35 PMnode:internal/modules/cjs/loader:1473

Feb 17 02:23:35 PM return process.dlopen(module, path.toNamespacedPath(filename));

Feb 17 02:23:35 PM ^

Feb 17 02:23:35 PM

Feb 17 02:23:35 PMError: /opt/render/project/src/backend/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header

Feb 17 02:23:35 PM at Module._extensions…node (node:internal/modules/cjs/loader:1473:18)

Feb 17 02:23:35 PM at Module.load (node:internal/modules/cjs/loader:1207:32)

Feb 17 02:23:35 PM at Module._load (node:internal/modules/cjs/loader:1023:12)

Feb 17 02:23:35 PM at Module.require (node:internal/modules/cjs/loader:1235:19)

Feb 17 02:23:35 PM at require (node:internal/modules/helpers:176:18)

Feb 17 02:23:35 PM at Object. (/opt/render/project/src/backend/node_modules/bcrypt/bcrypt.js:6:16)

Feb 17 02:23:35 PM at Module._compile (node:internal/modules/cjs/loader:1376:14)

Feb 17 02:23:35 PM at Module._extensions…js (node:internal/modules/cjs/loader:1435:10)

Feb 17 02:23:35 PM at Module.load (node:internal/modules/cjs/loader:1207:32)

Feb 17 02:23:35 PM at Module._load (node:internal/modules/cjs/loader:1023:12) {

Feb 17 02:23:35 PM code: ‘ERR_DLOPEN_FAILED’

Feb 17 02:23:35 PM}

Hi,

The invalid ELF header error usually occurs when you commit your node_modules folder that was created on a different OS.

It’s not recommended to commit node_modules into your repo, so that the package manager (npm, yarn, etc.) can determine the correct packages for the platform when installing.

Alan

1 Like

Does that mean you need to delete node_modules folder from git repository?

I did the same as you recommended but this time i receiving a different error …
at Module._load (node:internal/modules/cjs/loader:985:27)

Mar 7 07:12:51 PM at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)

Mar 7 07:12:51 PM- /opt/render/project/src/Api/index.js

Mar 7 07:12:51 PM- /opt/render/project/src/Api/routes/category.js

Mar 7 07:12:51 PMRequire stack:

Mar 7 07:12:51 PMError: Cannot find module ‘…/models/category’

Mar 7 07:12:51 PM

Mar 7 07:12:51 PM ^

Mar 7 07:12:51 PM throw err;

Mar 7 07:12:51 PMnode:internal/modules/cjs/loader:1147

Mar 7 07:12:48 PM

Mar 7 07:12:48 PM> node index.js

Mar 7 07:12:48 PM> nodes@1.0.0 start

Mar 7 07:12:48 PM

Mar 7 07:12:46 PM

You’ll need to check the filepaths are correct and nott hat Render use Linux with a case-senstive filesystem.

Ensure your code references to file are exactly as they are shown in GitHub. For example, you seem to have various casing in the logs you shared:

/Api/index.js

So maybe models and/or category are actually Models and/or Category?

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.