You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2026. It is now read-only.
Repository navigation
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
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
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.
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 :)
You could alias child_process to a module that fakes it all. I wonder how
you can use aws-sdk on the client side though, if it relies on
child_process.
On Sat, Feb 3, 2018, 10:25 AM Mars Wong, ***@***.***> wrote:
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 <https://github.com/kripken/sql.js> created by the
emscripten's author.
If you are still in troubles with integrating electron and sqlite, you
should have a try :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#909 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADWlnXqs9dajIb8PLigwtAXGBtD5WJIks5tRCYLgaJpZM4QfI5u>
.
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:
constnet=require('net')constport=process.env.PORT ? process.env.PORT-100 : 5000process.env.ELECTRON_START_URL=`http://localhost:${port}`constclient=newnet.Socket()letstartedElectron=falseconsttryConnection=()=>client.connect({port: port},()=>{client.end()if(!startedElectron){console.log('starting electron')startedElectron=trueconstexec=require('child_process').execexec('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.
Reacted by Ben Wurth, dylrich, Hendrik Bulens, Axel Kennedal and Chris Gray
@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?
@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...
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.
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
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');"
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 :)
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。 :)
Reacted by ntomes, KrasnovR, feng005211, victor-sanchez-ccc, shahriNidzam23, 巨佛, François Chastanet, vincent, Murilo Amaral Santiago and Nguyen Van Hanh
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')
Reacted by Jonathan Steven Barrero, Taylor Graham, sanderdebr, Zamin Hassnain, Raj Tukadiya, Dexter, darwin403, Mustafa AlAmmar, quocma, Paweł Waresiak and 12 more
Reacted by Karl Horky
Reacted by kirill-kostenetskyi, Alexandre Lorret, Yu, Joey Rider and dvorakchen
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.
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)
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.
Activity
RobertRajcool commentedon Nov 15, 2017
Can help me!!!
benschool commentedon Nov 15, 2017
npm install node-pre-gyp
RobertRajcool commentedon Nov 15, 2017
after install this package node-pre-gyp
getting lot of error
WARNING in ./
/node-pre-gyp/lib/util/compile.js/node-pre-gyp/lib/util/compile.js 39:27-49Module not found: Error: Can't resolve 'npm' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib/util'
@ ./
@ ./
/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/node-gyp/lib ^./.$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.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/node-pre-gyp/lib/info.js 14:14-32Module not found: Error: Can't resolve 'aws-sdk' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
@ ./
@ ./
/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/node-pre-gyp/lib/publish.js 17:14-32Module not found: Error: Can't resolve 'aws-sdk' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
@ ./
@ ./
/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/node-pre-gyp/lib/unpublish.js 15:14-32Module not found: Error: Can't resolve 'aws-sdk' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
@ ./
@ ./
/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/node-pre-gyp/lib/testbinary.js 10:9-33Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-pre-gyp/lib'
@ ./
@ ./
/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/node-pre-gyp/lib/util/compile.js 9:9-33Module 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 ^./.*$/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/detect-libc/lib/detect-libc.js 4:16-40Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/detect-libc/lib'
@ ./
@ ./
/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/node-gyp/lib/node-gyp.js 16:20-44Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
@ ./
@ ./
/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/osenv/osenv.js 3:11-35Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/osenv'
@ ./
@ ./
/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/node-gyp/lib/node-gyp.js 67:16-37Module not found: Error: Can't resolve '../package' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
@ ./
@ ./
/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/node-gyp/lib/build.js 14:11-35Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
@ ./
@ ./
/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/node-gyp/lib/configure.js 19:9-33Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
@ ./
@ ./
/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/node-gyp/lib/find-vs2017.js 2:15-39Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/node-gyp/lib'
@ ./
@ ./
/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/uid-number/uid-number.js 9:20-44Module not found: Error: Can't resolve 'child_process' in '/home/robert/electron/angular2-electron/node_modules/uid-number'
@ ./
@ ./
/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
wmertens commentedon Dec 26, 2017
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
gitsana commentedon Jan 26, 2018
I have this issue too. @RobertRajcool @wmertens any proposed solutions?
wmertens commentedon Jan 29, 2018
wmertens commentedon Feb 1, 2018
I saw this
child_processerror elsewhere: it was due to the dev using a module in a webpack build that importedchild_processsomewhere. Browsers cannot use node APIs, so be careful to not include it anywhere.marswong commentedon Feb 3, 2018
I had failed to build
sqlite3for thousand times no matter how, for theaws-sdkrelys onchild_processso every time yourequire('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
electronandsqlite, you should have a try :)wmertens commentedon Feb 3, 2018
barbalex commentedon Apr 4, 2018
I have same problem. On Windows. Using electron. Exact error is:
npm install --global --production windows-build-toolsis installed.child_processis only used node-side in my electron project to start electron after create-react-app has started:The exact same project structure and configuration works flawlessly in another project created yesterday that does not use native modules i.e. sqlite3.
axelkennedal commentedon Oct 9, 2018
@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?
barbalex commentedon Oct 9, 2018
@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...
dstrawsb commentedon Oct 17, 2018
mnmpeterson commentedon Feb 1, 2019
I'm getting this problem with fsevents on a Mac. Cannot find a solution.
wmertens commentedon Feb 2, 2019
@mnmpeterson try deleting node_modules, package-lock.json and/or yarn.lock, and install again
mnmpeterson commentedon Feb 2, 2019
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.
askogrand commentedon Feb 26, 2019
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
WilliamC07 commentedon Aug 11, 2019
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');"
mayurssoni2456 commentedon Oct 9, 2019
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.
Hey, Were you able to fix this issue after using boilerplate code and SQLite? curious to know :)
feng005211 commentedon Nov 22, 2019
This problem bothered me for three days, and now it's finally solved
Reference resources
#1029 (comment)
My solution:
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。 :)
Jclyoung commentedon Jan 15, 2020
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')
xtfer commentedon Apr 23, 2020
Not sure why this was closed. Issue still exists with node-sqlite3 built from HEAD at April 24th 2020.
rajtrydot commentedon Sep 13, 2020
Thanks @Jclyoung
const bcrypt = require('bcryptjs')
This was helpful to me
firien commentedon Nov 23, 2020
for webpack users trying to bundle sqlite3; there may be a better way to do this, but you can override the new
sqlite3-binding.jswithresolveand point to a different file.path/to/local/sqlite3-binding.js:
this approach requires the bindings package.
note: you will have to copy the
node_sqlite3.nodefile to specified directoriesdotgreg commentedon Jul 15, 2021
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)
karlhorky commentedon Feb 27, 2023
Anyone who decides to try @Jclyoung's recommendation above, I would suggest considering whether you really want to include
bcryptjsin your project - seems like an unmaintained library (GitHub) with the last publish in 2017.