最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - .node is not a valid Win32 application - Stack Overflow

programmeradmin1浏览0评论

On a Window 10 Home (on x64 bit), I tried running the following command on a Command Prompt:

node index.js

The error was the following:

C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\bindings\bindings.js:121 throw e; ^

Error: \?\C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\better-sqlite3\build\Release\better_sqlite3.node is not a valid Win32 application. \?\C:\Users\humay\OneDrive\Coding\sil\node_modules\better-sqlite3\build\Release\better_sqlite3.node at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18) 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:94:18) at bindings (C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\bindings\bindings.js:112:48) at Object. (C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\better-sqlite3\lib\database.js:9:24) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153: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:94:18) at Object. (C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\better-sqlite3\lib\index.js:2:18) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) { code: 'ERR_DLOPEN_FAILED' }

I'm using the following Node version: v16.6.2

On a Window 10 Home (on x64 bit), I tried running the following command on a Command Prompt:

node index.js

The error was the following:

C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\bindings\bindings.js:121 throw e; ^

Error: \?\C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\better-sqlite3\build\Release\better_sqlite3.node is not a valid Win32 application. \?\C:\Users\humay\OneDrive\Coding\sil\node_modules\better-sqlite3\build\Release\better_sqlite3.node at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18) 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:94:18) at bindings (C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\bindings\bindings.js:112:48) at Object. (C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\better-sqlite3\lib\database.js:9:24) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153: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:94:18) at Object. (C:\Users\cooldudeasateen\OneDrive\Coding\sil\node_modules\better-sqlite3\lib\index.js:2:18) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) { code: 'ERR_DLOPEN_FAILED' }

I'm using the following Node version: v16.6.2

Share Improve this question edited Aug 14, 2021 at 8:28 SImplehDUde asked Aug 12, 2021 at 12:27 SImplehDUdeSImplehDUde 1651 gold badge1 silver badge7 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 6

Now I don't need help, the problem was that I installed x86 instead of x64, which was an honest mistake.

How did I know that I made this mistake? Well, honestly, I looked at other files of other version of Nodejs, and it ended in x64 instead of x86. Honestly, it was my mistake and I should've looked at them before installing new Nodejs version.

For me I had to remove the node_modules folder and re-run npm install. Most likely because there was some issue when I first installed packages ...

I also made sure my node is x64 using node -p "process.arch" as mentioned in the comment.

Many node modules are just JavaScript and are portable across systems. Some, however, contain native compiled code. The SQLite library you are using is not 'pure JavaScript' and relies on a binary.

When you npm install-ed it installed a binary for the system you were using at that time, for example, you were on a Mac. The better_sqlite3.node file was for that specific operating system.

You then opened this project on a different computer but also copied over the node_modules directory. Just like how you can't run .app files on Windows or (usually) .exe on Linux, this binary is not compatible with your OS. Removing and then re-installing the SQLite library will install a Windows-compatible binary.

Since your project is in a OneDrive folder, it might be that you are switching between operating systems. That could make this process tedious. One workaround would be to install the SQLite module globally, but that has some drawbacks.

require() will look not just through the current directory, but also recursively directories above it (eg ...\OneDrive\Coding\sil, then ...\OneDrive\Coding, then ...\OneDrive), before checking the global directory.

发布评论

评论列表(0)

  1. 暂无评论