Skip to content
This repository was archived by the owner on Jul 1, 2026. It is now read-only.
This repository was archived by the owner on Jul 1, 2026. It is now read-only.

Module not found: Error: Can't resolve 'node-pre-gyp'  #909

Closed

Description

@RobertRajcool

ERROR in sqlite3/lib/sqlite3.js
Module not found: Error: Can't resolve 'node-pre-gyp' in

Activity

  1. RobertRajcool commented on Nov 15, 2017

    @RobertRajcool
    Author

    Can help me!!!

  2. benschool commented on Nov 15, 2017

    @benschool

    npm install node-pre-gyp

  3. RobertRajcool commented on Nov 15, 2017

    @RobertRajcool
    Author

    after install this package node-pre-gyp
    getting lot of error

    WARNING in .//node-pre-gyp/lib/util/compile.js
    Module not found: Error: Can't resolve 'npm' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib/util'
    @ ./
    /node-pre-gyp/lib/util/compile.js 39:27-49
    @ .//node-pre-gyp/lib ^./.*$
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    WARNING in .//node-gyp/lib/Find-VS2017.cs
    Module parse failed: /home/robert/electron/angular2-electron/node_modules/node-gyp/lib/Find-VS2017.cs Unexpected token (7:6)
    You may need an appropriate loader to handle this file type.
    | // Usage:
    | // powershell -ExecutionPolicy Unrestricted -Version "2.0" -Command "&{Add-Type -Path Find-VS2017.cs; [VisualStudioConfiguration.Main]::Query()}"
    | using System;
    | using System.Text;
    | using System.Runtime.InteropServices;
    @ ./
    /node-gyp/lib ^./.$
    @ .//node-gyp/lib/node-gyp.js
    @ ./
    /node-pre-gyp/lib/util/compile.js
    @ ./~/node-pre-gyp/lib ^./.
    $
    @ .//node-pre-gyp/lib/node-pre-gyp.js
    @ ./
    /sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    WARNING in ./~/sqlite3/lib/sqlite3.js
    4:14-35 Critical dependency: the request of a dependency is an expression

    WARNING in ./~/node-pre-gyp/lib/pre-binding.js
    19:22-48 Critical dependency: the request of a dependency is an expression

    WARNING in ./~/node-pre-gyp/lib/util/versioning.js
    16:20-67 Critical dependency: the request of a dependency is an expression

    ERROR in .//node-pre-gyp/lib/info.js
    Module not found: Error: Can't resolve 'aws-sdk' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
    @ ./
    /node-pre-gyp/lib/info.js 14:14-32
    @ .//node-pre-gyp/lib ^./.*$
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-pre-gyp/lib/publish.js
    Module not found: Error: Can't resolve 'aws-sdk' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
    @ ./
    /node-pre-gyp/lib/publish.js 17:14-32
    @ .//node-pre-gyp/lib ^./.*$
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-pre-gyp/lib/unpublish.js
    Module not found: Error: Can't resolve 'aws-sdk' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
    @ ./
    /node-pre-gyp/lib/unpublish.js 15:14-32
    @ .//node-pre-gyp/lib ^./.*$
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-pre-gyp/lib/testbinary.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
    @ ./
    /node-pre-gyp/lib/testbinary.js 10:9-33
    @ .//node-pre-gyp/lib ^./.*$
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-pre-gyp/lib/util/compile.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib/util'
    @ ./
    /node-pre-gyp/lib/util/compile.js 9:9-33
    @ .//node-pre-gyp/lib ^./.*$
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//detect-libc/lib/detect-libc.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/detect-libc/lib'
    @ ./
    /detect-libc/lib/detect-libc.js 4:16-40
    @ .//node-pre-gyp/lib/util/versioning.js
    @ ./
    /node-pre-gyp/lib ^./.*$
    @ .//node-pre-gyp/lib/node-pre-gyp.js
    @ ./
    /sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-gyp/lib/node-gyp.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
    @ ./
    /node-gyp/lib/node-gyp.js 16:20-44
    @ .//node-pre-gyp/lib/util/compile.js
    @ ./
    /node-pre-gyp/lib ^./.*$
    @ .//node-pre-gyp/lib/node-pre-gyp.js
    @ ./
    /sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//osenv/osenv.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/osenv'
    @ ./
    /osenv/osenv.js 3:11-35
    @ .//nopt/lib/nopt.js
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-gyp/lib/node-gyp.js
    Module not found: Error: Can't resolve '../package' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
    @ ./
    /node-gyp/lib/node-gyp.js 67:16-37
    @ .//node-pre-gyp/lib/util/compile.js
    @ ./
    /node-pre-gyp/lib ^./.*$
    @ .//node-pre-gyp/lib/node-pre-gyp.js
    @ ./
    /sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-gyp/lib/build.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
    @ ./
    /node-gyp/lib/build.js 14:11-35
    @ .//node-gyp/lib ^./.*$
    @ ./
    /node-gyp/lib/node-gyp.js
    @ .//node-pre-gyp/lib/util/compile.js
    @ ./
    /node-pre-gyp/lib ^./.*$
    @ .//node-pre-gyp/lib/node-pre-gyp.js
    @ ./
    /sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-gyp/lib/configure.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
    @ ./
    /node-gyp/lib/configure.js 19:9-33
    @ .//node-gyp/lib ^./.*$
    @ ./
    /node-gyp/lib/node-gyp.js
    @ .//node-pre-gyp/lib/util/compile.js
    @ ./
    /node-pre-gyp/lib ^./.*$
    @ .//node-pre-gyp/lib/node-pre-gyp.js
    @ ./
    /sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//node-gyp/lib/find-vs2017.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
    @ ./
    /node-gyp/lib/find-vs2017.js 2:15-39
    @ .//node-gyp/lib ^./.*$
    @ ./
    /node-gyp/lib/node-gyp.js
    @ .//node-pre-gyp/lib/util/compile.js
    @ ./
    /node-pre-gyp/lib ^./.*$
    @ .//node-pre-gyp/lib/node-pre-gyp.js
    @ ./
    /sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

    ERROR in .//uid-number/uid-number.js
    Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/uid-number'
    @ ./
    /uid-number/uid-number.js 9:20-44
    @ .//tar-pack/index.js
    @ ./
    /node-pre-gyp/lib/package.js
    @ .//node-pre-gyp/lib ^./.*$
    @ ./
    /node-pre-gyp/lib/node-pre-gyp.js
    @ ./~/sqlite3/lib/sqlite3.js
    @ ./src/app/login/login.component.ts
    @ ./src/app/app.module.ts
    @ ./src/main.ts
    @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

  4. wmertens commented on Dec 26, 2017

    @wmertens
    Contributor

    Do you still have this issue? This seems to be a Node configuration issue. Unless you can show how to reproduce this on a recent Node install, I propose that you close this issue

  5. gitsana commented on Jan 26, 2018

    @gitsana

    I have this issue too. @RobertRajcool @wmertens any proposed solutions?

  6. wmertens commented on Jan 29, 2018

    @wmertens
    Contributor
  7. wmertens commented on Feb 1, 2018

    @wmertens
    Contributor

    I saw this child_process error elsewhere: it was due to the dev using a module in a webpack build that imported child_process somewhere. Browsers cannot use node APIs, so be careful to not include it anywhere.

  8. marswong commented on Feb 3, 2018

    @marswong

    I had failed to build sqlite3 for thousand times no matter how, for the aws-sdk relys on child_process so every time you require('sqlite3') on client side it could not be resolved.

    Luckily, I found an awesome module can work like a charm on both client or server side - sql.js created by the emscripten's author.

    If you are still in troubles with integrating electron and sqlite, you should have a try :)

  9. wmertens commented on Feb 3, 2018

    @wmertens
    Contributor
  10. barbalex commented on Apr 4, 2018

    @barbalex

    I have same problem. On Windows. Using electron. Exact error is:

    ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/info.js
    Module not found: Can't resolve 'aws-sdk' in 'C:\Users\alexa\kapla4\node_modules\sqlite3\node_modules\node-pre-gyp\lib'
    

    npm install --global --production windows-build-tools is installed.

    child_process is only used node-side in my electron project to start electron after create-react-app has started:

    const net = require('net')
    const port = process.env.PORT ? process.env.PORT - 100 : 5000
    
    process.env.ELECTRON_START_URL = `http://localhost:${port}`
    
    const client = new net.Socket()
    
    let startedElectron = false
    const tryConnection = () =>
      client.connect({ port: port }, () => {
        client.end()
        if (!startedElectron) {
          console.log('starting electron')
          startedElectron = true
          const exec = require('child_process').exec
          exec('yarn run electron')
        }
      })
    
    tryConnection()
    
    client.on('error', error => {
      setTimeout(tryConnection, 1000)
    })

    The exact same project structure and configuration works flawlessly in another project created yesterday that does not use native modules i.e. sqlite3.

  11. axelkennedal commented on Oct 9, 2018

    @axelkennedal

    @barbalex I'm getting the exact same error message when trying to use Sequelize (which depends on sqlite3) together with Electron, any clue how to solve this?

  12. barbalex commented on Oct 9, 2018

    @barbalex

    @axelkennedal I ended up not using create-react-app but instead electron-react-boilerplate which solves the problem by using another package.json file - somehow...

  13. dstrawsb commented on Oct 17, 2018

    @dstrawsb

    @barbalex I'm also getting same error message with Sequelize, irritating, i'm not using sqlLite3.

  14. mnmpeterson commented on Feb 1, 2019

    @mnmpeterson

    I'm getting this problem with fsevents on a Mac. Cannot find a solution.

  15. wmertens commented on Feb 2, 2019

    @wmertens
    Contributor

    @mnmpeterson try deleting node_modules, package-lock.json and/or yarn.lock, and install again

  16. mnmpeterson commented on Feb 2, 2019

    @mnmpeterson

    Did that, same problem. This is on an angularjs 1.6 project. On an angular 6.x project sfevents will download and compile what it needs from node-gyp but won’t do the same on my angularjs projects.

  17. askogrand commented on Feb 26, 2019

    @askogrand

    For what its worth — I've run into the same problem. Deleting node_modules and lock files doesnt help, nor does adding node-pre-gyp globally. I think I too will use the other boilerplate

  18. WilliamC07 commented on Aug 11, 2019

    @WilliamC07

    If you are using electron, I used the package "electron-rebuild" to fix this.
    I ran the command "./node_modules/.bin/electron-rebuild -f -w sqlite3"
    To use sqlite, use "const sqlite = window.require('sqlite3');"

  19. mayurssoni2456 commented on Oct 9, 2019

    @mayurssoni2456

    hi all, I am facing the same issue on Mac. Is anyone able to solve this problem?
    I tried almost all solution available. Still no luck.

    For what its worth — I've run into the same problem. Deleting node_modules and lock files doesnt help, nor does adding node-pre-gyp globally. I think I too will use the other boilerplate

    Hey, Were you able to fix this issue after using boilerplate code and SQLite? curious to know :)

  20. feng005211 commented on Nov 22, 2019

    @feng005211

    This problem bothered me for three days, and now it's finally solved
    Reference resources
    #1029 (comment)

    My solution:

      output: {
        path: config.build.assetsRoot,
        filename: '[name].js',
        publicPath: process.env.NODE_ENV === 'production'
          ? config.build.assetsPublicPath
          : config.dev.assetsPublicPath,
          libraryTarget: 'commonjs2'
      },
      externals: {
          sqlite3: 'sqlite3'
      }
    

    important code
    libraryTarget: 'commonjs2'
    sqlite3: 'sqlite3'

    If you solve this problem because of my solution, please share it with those who need help. And use this link。 :)

  21. Jclyoung commented on Jan 15, 2020

    @Jclyoung

    This was happening to me because I was pointing to the wrong dependency

    in my case, it was bcrypt that was causing the issue

    error received when using :
    const bcrypt = require('bcrypt')

    error fixed when using :
    const bcrypt = require('bcryptjs')

  22. xtfer commented on Apr 23, 2020

    @xtfer

    Not sure why this was closed. Issue still exists with node-sqlite3 built from HEAD at April 24th 2020.

  23. rajtrydot commented on Sep 13, 2020

    @rajtrydot

    Thanks @Jclyoung

    const bcrypt = require('bcryptjs')

    This was helpful to me

  24. firien commented on Nov 23, 2020

    @firien

    for webpack users trying to bundle sqlite3; there may be a better way to do this, but you can override the new sqlite3-binding.js with resolve and point to a different file.

    resolve: {
      alias: {
        [path.join(__dirname, 'node_modules/sqlite3/lib/sqlite3-binding.js')]: path.join(__dirname, 'path/to/local/sqlite3-binding.js')
      }
    }

    path/to/local/sqlite3-binding.js:

    var binding = require('bindings')('node_sqlite3');
    module.exports = exports = binding;

    this approach requires the bindings package.

    npm install bindings --save-dev

    note: you will have to copy the node_sqlite3.node file to specified directories

  25. dotgreg commented on Jul 15, 2021

    @dotgreg

    July 2021, still having that issue with webpack + sqlite3 on linux
    I managed however to solve it by modifying my webpack config file as that comment suggests
    #1029 (comment)

  26. karlhorky commented on Feb 27, 2023

    @karlhorky

    This was happening to me because I was pointing to the wrong dependency

    in my case, it was bcrypt that was causing the issue

    error received when using : const bcrypt = require('bcrypt')

    error fixed when using : const bcrypt = require('bcryptjs')

    Anyone who decides to try @Jclyoung's recommendation above, I would suggest considering whether you really want to include bcryptjs in your project - seems like an unmaintained library (GitHub) with the last publish in 2017.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions