Skip to content

Couldn't run in Electron project with electron-forge #1810

Closed

Description

@CyberNika

I wanna use Sharp in my Electron project which is using electron-forge. I'v tried my best to run it, but never succeed.

Here are the errors I got.

image


What is the output of running npm install --verbose sharp?

npm info it worked if it ends with ok
npm verb cli [ '/usr/local/Cellar/node/11.14.0_1/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'install',
npm verb cli   '--verbose',
npm verb cli   'sharp' ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session 19bc0bbc297ae013
npm http fetch GET 304 https://registry.npm.taobao.org/sharp 330ms (from cache)
npm timing stage:loadCurrentTree Completed in 1392ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 8ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 514ms
npm http fetch GET 304 https://registry.npm.taobao.org/color 93ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/fs-copy-file-sync 162ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/prebuild-install 179ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/simple-get 180ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/color-string 64ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/simple-swizzle 78ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/is-arrayish 235ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/noop-logger 87ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/expand-template 95ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/napi-build-utils 100ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/minimist 111ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/tar-fs 157ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/which-pm-runs 159ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/github-from-package 202ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/simple-concat 78ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/pump 92ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/tar-stream 108ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/bl 98ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/to-buffer 112ms (from cache)
npm http fetch GET 304 https://registry.npm.taobao.org/fs-constants 118ms (from cache)
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 1720ms
npm timing stage:loadIdealTree Completed in 2435ms
npm timing stage:generateActionsToTake Completed in 60ms
npm verb correctMkdir /Users/yons/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /Users/yons/.npm/_locks/staging-118a6f3160b498a1.lock for /Users/yons/repos/project/onebox/node_modules/.staging
npm timing action:extract Completed in 37ms
npm info lifecycle [email protected]~preuninstall: [email protected]
npm info lifecycle [email protected]~uninstall: [email protected]
npm verb unbuild rmStuff [email protected] from /Users/yons/repos/project/onebox/node_modules
npm info lifecycle [email protected]~postuninstall: [email protected]
npm timing action:unbuild Completed in 2ms
npm timing action:remove Completed in 142ms
npm timing action:finalize Completed in 2ms
npm timing action:refresh-package-json Completed in 5ms
npm info lifecycle [email protected]~preinstall: [email protected]
npm timing action:preinstall Completed in 0ms
npm info linkStuff [email protected]
npm timing action:build Completed in 1ms
npm info lifecycle [email protected]~install: [email protected]

> [email protected] install /Users/yons/repos/project/onebox/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /Users/yons/.npm/_libvips/libvips-8.7.4-darwin-x64.tar.gz
prebuild-install info begin Prebuild-install version 5.3.0
prebuild-install info looking for cached prebuild @ /Users/yons/.npm/_prebuilds/9573dc-sharp-v0.22.1-node-v64-darwin-x64.tar.gz
prebuild-install info found cached prebuild
prebuild-install info unpacking @ /Users/yons/.npm/_prebuilds/9573dc-sharp-v0.22.1-node-v64-darwin-x64.tar.gz
prebuild-install info unpack resolved to /Users/yons/repos/project/onebox/node_modules/sharp/build/Release/sharp.node
prebuild-install info unpack required /Users/yons/repos/project/onebox/node_modules/sharp/build/Release/sharp.node successfully
prebuild-install info install Successfully installed prebuilt binary!
npm verb lifecycle [email protected]~install: unsafe-perm in lifecycle true
npm verb lifecycle [email protected]~install: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/yons/repos/project/onebox/node_modules/sharp/node_modules/.bin:/Users/yons/repos/project/onebox/node_modules/.bin:/usr/local/opt/[email protected]/bin:/usr/dev/flutter/bin:/Users/yons/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
npm verb lifecycle [email protected]~install: CWD: /Users/yons/repos/project/onebox/node_modules/sharp
npm timing audit submit Completed in 1402ms
npm http fetch POST 200 https://registry.npm.taobao.org/-/npm/v1/security/audits/quick 1402ms
npm timing audit body Completed in 1ms
npm timing action:install Completed in 3564ms
npm info lifecycle [email protected]~postinstall: [email protected]
npm timing action:postinstall Completed in 1ms
npm verb unlock done using /Users/yons/.npm/_locks/staging-118a6f3160b498a1.lock for /Users/yons/repos/project/onebox/node_modules/.staging
npm timing stage:executeActions Completed in 3770ms
npm timing stage:rollbackFailedOptional Completed in 0ms
npm timing stage:runTopLevelLifecycles Completed in 7859ms
npm verb saving [ { name: 'sharp', spec: '^0.22.1', save: 'dependencies' } ]
npm verb shrinkwrap skipping write for package.json because there were no changes.
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm verb shrinkwrap skipping write for package-lock.json because there were no changes.
npm info lifecycle undefined~postshrinkwrap: undefined
npm WARN [email protected] No repository field.

+ [email protected]
updated 1 package and audited 14860 packages in 8.241s
found 0 vulnerabilities

npm verb exit [ 0, true ]
npm timing npm Completed in 8519ms
npm info ok

What is the output of running npx envinfo --binaries --languages --system --utilities?

$ npx envinfo --binaries --languages --system --utilities
npx: installed 1 in 0.964s

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    Memory: 1.23 GB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.0 - /usr/local/bin/node
    npm: 6.9.0 - /usr/local/bin/npm
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Git: 2.21.0 - /usr/local/bin/git
  Languages:
    Bash: 3.2.57 - /bin/bash
    Perl: 5.18.2 - /usr/bin/perl
    PHP: 7.1.16 - /usr/bin/php
    Python: 2.7.10 - /usr/bin/python
    Ruby: 2.3.7 - /usr/bin/ruby
    Rust: 1.18.3 - /Users/yons/.cargo/bin/rustup

Have you ensured the platform and version of Node.js used for npm install is the same as the platform and version of Node.js used at runtime?

Yes, I'm sure

Activity

  1. lovell commented on Jul 28, 2019

    @lovell
    Owner

    Are you using https://github.com/electron/electron-rebuild, which is required when using native modules with Electron?

  2. CyberNika commented on Jul 28, 2019

    @CyberNika
    Author

    Yes. And I've tried to run ./node_modules/.bin/electron-rebuild myself. But nothing happened.

  3. lovell commented on Jul 28, 2019

    @lovell
    Owner

    It might be something to do with asarUnpack - see #678 (comment) for the most "liked" suggestion relating to this.

  4. CyberNika commented on Jul 30, 2019

    @CyberNika
    Author

    Hi, lovell. Thanks for your help. I tried to set config to asarUnpack, but it doesn't work yet. I think maybe it's a problem with electron-forge.

  5. jimmy-tfp commented on Aug 15, 2019

    @jimmy-tfp

    hate to red-herring this, but with electron 6.0.2 all the packages seem to want to install in "devDependencies" but my setup would not load sharp unless it was in the regular "dependencies". ymmv.

  6. CyberNika commented on Aug 17, 2019

    @CyberNika
    Author

    Hi all,
    When I upgrade electron to 6.0.2 and electron-forge to 6.0.0-beta.44, it does work! It's absolutely perfect!

  7. aperkaz commented on Apr 11, 2021

    @aperkaz

    For future reference, I built a working example of electron-forge and sharp:
    https://github.com/aperkaz/electron-forge-sharp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions