Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not a valid Win32 Application #1533

Closed
grumbaut opened this issue Mar 12, 2020 · 7 comments
Closed

Not a valid Win32 Application #1533

grumbaut opened this issue Mar 12, 2020 · 7 comments

Comments

@grumbaut
Copy link

Issue or Feature

I'm using node-canvas along with PDF.js to transform PDFs into images, as shown in their pdf2png example.

I included this in a command line tool that was built and published on a Mac, and can run it just fine there. However, on Windows, I'm getting the following error:

internal/modules/cjs/loader.js:1208
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: \\?\C:\Users\grumbaut\Documents\books\westcivbr\node_modules\canvas\build\Release\canvas.node is not a valid Win32 application.
\\?\C:\Users\grumbaut\Documents\books\westcivbr\node_modules\canvas\build\Release\canvas.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1208:18)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\Users\grumbaut\Documents\books\westcivbr\node_modules\canvas\lib\bindings.js:3:18)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)

I'm using NVM and have confirmed that I have a 64-bit version of both Windows and Node installed. I also tested this out using a 32-bit version of Node and am still getting the same errors.

This is a blocker for a few people, so any help would be appreciated.

Steps to Reproduce

Your Environment

  • Version of node-canvas (output of npm list canvas or yarn list canvas): 2.6.1
  • Environment (e.g. node 4.2.0 on Mac OS X 10.8): node 12.16.1 on Windows 10 64-bit
@zbjornson
Copy link
Collaborator

My guess is it's still something to do with NVM and 32 vs. 64-bit. If you're using npm, you can try overriding the target arch with npm install canvas --target_arch=ia32 or x64 (last I checked yarn does not forward flags).

@aspasov86
Copy link

aspasov86 commented Mar 25, 2020

I'm having the same problem...
Tried npm install canvas --target_arch=ia32 and it didn't work for me.

@zbjornson
Copy link
Collaborator

zbjornson commented Apr 26, 2020

There's not enough info here to troubleshoot, so I'm going to close this for now.

If anyone wants to troubleshoot further, can you please post:

node -p "process.arch"

and

const fs = require("fs");
const path = require("path");
const cnode = path.join(require.resolve("canvas"), "../build/Release/canvas.node");
const fd = fs.openSync(cnode);
const b = Buffer.alloc(4);
fs.readSync(fd, b, 0, 4, 60);
const pe_addr = b.readUInt32LE(0);
fs.readSync(fd, b, 0, 2, pe_addr + 4);
const type = b.readUInt16LE(0);
console.log(type.toString(16));

That will print one of the values here, which should be 8664 (64-bit) or 14c (32-bit).

@LoganDark
Copy link

@zbjornson I'm having this issue with another library, fs-ext - my Node installation is 64-bit and so is the binary:

image

Past that, are there any extra troubleshooting steps that you might have? I understand if you don't have any since this is a different library - but anything helps. Thanks!

@LoganDark
Copy link

Nevermind, node-loader is being really, really dumb

image

Disregard my previous comment lol

@zbjornson
Copy link
Collaborator

@LoganDark could you share some more info on what was going wrong so I can add it to the installation troubleshooting guide please? There have been quite a few issues opened for "not a valid Win32 application" that weren't due to 64/32-bit mismatches. Maybe some were due to node-loader.

@LoganDark
Copy link

LoganDark commented Aug 19, 2021

@LoganDark could you share some more info on what was going wrong so I can add it to the installation troubleshooting guide please? There have been quite a few issues opened for "not a valid Win32 application" that weren't due to 64/32-bit mismatches. Maybe some were due to node-loader.

It was fixed by this PR electron/forge#2449 that was just recently merged. Making the patch manually fixes the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants