how to install sqlite3 in electron? - node.js

So here is what i did, i installed electron and sqlite3 inside my project directory
npm install electron --save-dev
npm install sqlite3
but when i try to run this using npm start it gives me error
var sqlite3 = require('sqlite3').verbose();
this line is inside my main.js where i initialize electron things etc. and it works fine without this line.
here's the error i get.
Uncaught Exception:
Error: Cannot find module '/home/touseef/Desktop/Projects/pos/node_modules/sqlite3/lib/binding/electron-v6.0-linux-x64/node_sqlite3.node'
Require stack:
- /home/touseef/Desktop/Projects/pos/node_modules/sqlite3/lib/sqlite3.js
- /home/touseef/Desktop/Projects/pos/main.js
- /home/touseef/Desktop/Projects/pos/node_modules/electron/dist/resources/default_app.asar/main.js
-
at Module._resolveFilename (internal/modules/cjs/loader.js:627:15)
at Function.Module._resolveFilename (/home/touseef/Desktop/Projects/pos/node_modules/electron/dist/resources/electron.asar/common/reset-search-paths.js:41:16)
at Function.Module._load (internal/modules/cjs/loader.js:531:27)
at Module.require (internal/modules/cjs/loader.js:685:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/home/touseef/Desktop/Projects/pos/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (internal/modules/cjs/loader.js:786:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
at Module.load (internal/modules/cjs/loader.js:645:32)
at Function.Module._load (internal/modules/cjs/loader.js:560:12)
My node version is 10.16.3 and i'm running Ubuntu.

Just had this issue too. I had to rebuild sqlite3.
Installed electron-rebuild, and added "scripts": { "rebuild": "electron-rebuild -f -w sqlite3" },
to my package.json. Then executed npm run rebuild, and let it rebuild. Got rid of this error for me.

Related

Error: Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin' Require stack:

I have webpack-cli installed on my laravel project. I don't know why first of all we need it to run my vue app but this is causing an error:
When I run npm run dev or npm run hot
[webpack-cli] Error: Cannot find module 'webpack/lib/rules/DescriptionDataMatcherRulePlugin'
Require stack:
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin-webpack5.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\index.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\components\Vue.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\components\ComponentRegistrar.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\src\Mix.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\laravel-mix\setup\webpack.config.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\lib\webpack-cli.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\lib\bootstrap.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack-cli\bin\cli.js
- C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\webpack\bin\webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (C:\Users\Viruss\Desktop\test-meme-library\meme-library\node_modules\vue-loader\lib\plugin-webpack5.js:6:42)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\plugin-webpack5.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\plugin.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\vue-loader\\lib\\index.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\components\\Vue.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\components\\ComponentRegistrar.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\src\\Mix.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\laravel-mix\\setup\\webpack.config.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\lib\\webpack-cli.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\lib\\bootstrap.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack-cli\\bin\\cli.js',
'C:\\Users\\Viruss\\Desktop\\test-meme-library\\meme-library\\node_modules\\webpack\\bin\\webpack.js'
]
}
Vue is installed also vue-loader, can't understand why it can't find those files. Also, I looked at the node_modules everything is in there ...
You need to update your vue-loader
npm update vue-loader
And if it is not installed, install it
npm i vue-loader
Laravel added the 15.9.7 version of Vue-loader by default. I have to manually update the vue-loader:^15.9.8 in the package JSON to solve the error.
Then do yarn and yarn dev or npm install and npm run dev
I had this error in my project. After searching for it, I discovered that I have to upgrade the Vue loader. And if not installed, go ahead and install it from here. So I add this line to my terminal in my project.
npm install -D vue-loader vue-template-compiler
running
npm update vue-loader
should do the work just fine if the vue-loader package is already installed.
Some of those updates are major releases. Running npm update won’t update the version of those. Major releases are never updated in this way because they (by definition) introduce breaking changes, and npm want to save you trouble.
Some times npm packages not gets installed properly, i used following method to resolve this problem:
**
Delete node modules folder from your project.
Execute following commands
npm install -g npm-check-updates
ncu -u
npm install/update.**

React Native CLI, Cannot find module '/usr/local/lib/node_modules/react-native-cli/node_modules/prompt/lib/prompt'

I'm having a problem installing the react native CLI
When I run react-native init or any other cli method
internal/modules/cjs/loader.js:296
throw err;
^
Error: Cannot find module '/usr/local/lib/node_modules/react-native-cli/node_modules/prompt/lib/prompt'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:288:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:515:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:759:27)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:43:14)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32) {
code: 'MODULE_NOT_FOUND',
path: '/usr/local/lib/node_modules/react-native-cli/node_modules/prompt/package.json',
requestPath: 'prompt'
}
Removed and re-installed using npm install -g react-native-cli but no luck.
node version v12.10.0,
npm version 6.10.3
This was resolved by completely removing Node and re-installing using homebrew
I was resolved by removing node and remove this folder /usr/local/lib/node_modules/react-native-cli/node_modules/ and reinstall node
run command (yarn add npm) if you have yarn
I have resolved my issue with this command

Cannot find module 'iconv'

After I installed gulp,I execute the following command
I tried following steps,
1.npm install
versions
npm :- 6.9.0,
node :- 10.15.13,
python :- 2.7.10
2.npm install gulp
versions
CLI version :- 3.9.1,
Local version :- 3.9.1
And I Also tried globaly,its also showing same error
> npm install -g gulp
After Install gulp in above version and run the following command
gulp like
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'iconv'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\cygwin64\home\D-218\workspace\shima\src\tasks\json.js:4:14)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
You have only installed Gulp on you system. Gulp is a task runner. One of your tasks requires using iconv. The error is showing the module "iconv" is not found. Install it with the below, add "-g" if you want install system wide rather than just in this project directory.
npm install iconv
Then in your gulp file import iconv with a line as follows:
var Iconv = require('iconv').Iconv;
Rerun your task and it should execute fine.

Error: Cannot find module 'commander'

when I m running sails -v, sails lift or even installing npm I m getting this error Please help -
Error: Cannot find module 'commander'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/sails/bin/_commander.js:6:15)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Most likely commander is missing from package.json. Install it and add it to package.json by doing:
npm install commander --save
Install commander globally.
sudo npm install commander -g
This will install commander module under/usr/lib/node_modules/.
Uninstalling sails and reinstalling with 'sudo' resolved it.
npm uninstall sails -g
sudo npm install sails -g
When i try setup new app with the help of express-generator.
given error:Cannot find module 'commander'
Node version:12.16.1
switch node version :10.16.3
after switch node version is working fine..
In my case it was because of bad version of node. I've tried node 8.15.1 and it works.
On my end, after doing npm install, and attempt to run npm run watch I encountered this same issue of Error: Cannot find module 'commander'.
I did below:
// delete node_modules (can do manually) or command below
// rm -rf node_modules
npm install
And I was able to do npm run watch again.
This maybe because of corrupted packages.

create-react-app in WebStorm

I am attempting to use the npm package "create-react-app" to get started on a react project using WebStorm.
I have run npm install -g create-react-app to install the package globally, and can use the package perfectly fine with from the command line (i.e. create-react-app <proj name>).
However when creating a project in WebStorm and using the path to the global "create-react-app" package (found using npm list -g), I encounter this error:
/usr/bin/node /usr/local/lib/node_modules/create-react-app/index.js .
/usr/local/lib/node_modules/create-react-app/createReactApp.js:589
.filter(file => !validFiles.includes(file));
^
TypeError: validFiles.includes is not a function
at /usr/local/lib/node_modules/create-react-
app/createReactApp.js:589:33
at Array.filter (native)
at isSafeToCreateProjectIn (/usr/local/lib/node_modules/create-
react-app/createReactApp.js:589:6)
at createApp (/usr/local/lib/node_modules/create-react-
app/createReactApp.js:147:8)
at Object.<anonymous> (/usr/local/lib/node_modules/create-react-
app/createReactApp.js:134:1)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
Done
Have I gone wrong at some point?
It turns out I had node version 4, and create-react-app requires version >= 6 - although this warning was not displayed via the WebStorm "Run" panel.
Thus I fixed this issue by updating to node v6.11.3, using nvm.

Resources