When I try to build my applicaton using electron it crashes on leveldown library
Error: The module '/Users/macosx/Documents/Electron/node_modules/leveldown/build/Release/leveldown.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
I have tried
rm -rf node_modules/leveldown
npm install
npm rebuild leveldown--update-binary
npm uninstall leveldown
Also tried this
I had the same problem and nothing mentioned here worked for me. Here is what >worked for me:
Require all dependencies you need in the main.js file that is run by
electron. (this seemed to be the first important part for me) Run npm
i -D electron-rebuild to add the electron-rebuild package Remove the
node-modules folder, as well as the packages-lock.json file. Run npm i
to install all modules. Run ./node_modules/.bin/electron-rebuild to
rebuild everything It is very important to run
./node_modules/.bin/electron-rebuild directly after npm i otherwise it
did not work on my mac.
I struggled with this for a couple days. The trick is to use electron-rebuild to build the native node module, and to include the option node.__dirname = true in your webpack config, as the leveldown bindings.js depend on the __dirname global provided by Node.
Related
Good morning,
I have created a program in Vue JS, this connects with an API that I have created in a main.js file to execute system commands.
The problem I have is that when compiling for production with electron I get the following error:
I use the command npm run electron: build
When I use npm run electron:serve work without problems
Anyone have any idea why is the error and how to fix it?
Thanks
I experienced this issue a few days ago as well. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the npm install command. This made the build to fail with 'fs/promises'. There are 2 solutions to this issue:
Download the latest stable Node version. This should have the 'fs/promises' module and will fix the issue.
Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same. Then run the npm install command and the issue should be fixed.
downgrade electron
"electron-builder": "^22.10.5",
or upgrade nodejs to 14+ v
downgrade to "electron-builder": "~22.10.5" is working for me
In that case I fixed the problem in that way:
const fs = require('fs').promises;
Instead of:
const fs = require('fs/promises');
In my case I was using nvm to manage multiple node versions.
During the npm package installation, and throughout development, I used Node v14 but for some reason, my terminal was pointing to Node v12 when I tried bundling my program afterwards.
Switching it back to Node v14 using nvm use 14 solved my issue.
So make sure you're using the correct node version.
Upgrade to electron-updater#5.0.0. It has patch changes replacing fs/promises with fs-extra to support legacy versions of electron.
got the same error "Cannot find module 'fs/promises'" while I don't use electron.
so the problem is not only related to electron
solved the problem just by upgrading nodejs from v13.9.0 to v14.19.3
If this happens to you (and I'm not using Electron either), and you have to stay on Node 12 like me (because the code you are maintaining is ancient), pray that you can get to one of the npm-shrinkwrap.json files you used that worked, then go through package.json, force every version to what was in the shrinkwrap file, rm -rf node_modules, and npm install.
I experienced this issue a few days ago. I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the
npm install
This made the build to fail with 'fs/promises'.
Delete the node_modules folder and bring back the old package-lock.json file to ensure that the package versions remain the same
then run the npm command with force
npm install --force
it work for me..
I had the same problem, after upgrading the electron-builder from v. 21.4.0 to 23.0.2, updated with the command:
sudo npm install -g electron-builder#23.0.2
I solved updating npm, and then node.js.
Update npm:
sudo npm install -g npm#latest
Install nodejs from https://nodejs.org
Now it works with :
Electron-builder: 23.0.2 (command electron-builder --version)
Npm: 8.7.0 (command npm --version)
Nodejs: v16.15.0 (command node --version)
when i run command npm start, i am getting this error
Error: The module '/var/www/oxygen/mirari-api/node_modules/bcrypt/lib/binding/bcrypt_lib.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 59. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
can anyone please help me how to resolve this issue ? i am using node version 10.13.0, i tried a lot googling but it didn't help me yet, if anyone have face that issue then please let me know, thanks
This error happens when you install your npm modules with different version and then try to run you code it with another version. Try deleting your node_modules folder and reinstalling them.
have you tried re-installing it?
There is a simillar question here:
Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51
Resuming, you could try:
$ rm -rf node_modules/bcrypt
$ npm install
// or
$ yarn
Or:
1- Require all dependencies you need in the main.js file that is run by electron. (this seemed to be the first important part for me)
2- Run npm i -D electron-rebuild to add the electron-rebuild package
3- Remove the node-modules folder, as well as the packages-lock.json file.
4- Run npm i to install all modules.
5- Run ./node_modules/.bin/electron-rebuild (.\node_modules.bin\electron-rebuild.cmd for Windows) to rebuild everything
I've just installed the babel-cli module locally to my project but when I run babel test.js in the terminal it outputs that the *command babel is uknown*.
What I figured out is that npm is trying to find the module in my globally installed modules instead of my project modules, how can I fix it?
Sorry for the silly question but I'm not finding a solution.
You can either
Use the babel installed in you project - node_modules/.bin/babel test.js
Add a script in your package.json and run it via npm - npm run <script_name>. npm will use the version of babel installed in your project
When you run babel. It looks for global npm directory and can't find it there.
2 ways but one is redundant.
You can link your local path to global npm directory which is
redundant and wont work for the next project. Don't never do this.
Or install it globally. That how npm works for now.
There is a discussion on that. And here is a good article. http://www.joezimjs.com/javascript/no-more-global-npm-packages/
I've been using ember for a while and when I wanted to install the node dependencies of a project, I just needed to use npm install to create the folder node_modules with all the dependencies (as it's described in http://ember-cli.com/user-guide/).
Since I was using an old version of node I unisntalled node and npm and installed nvm with the versions node v5.0.0 and npm v3.3.6but now, when I try to use npm install to install the dependencies of a project as I used to do before, instead of the dependencies of the package.json file, I get many, many more from things I'm not sure where they come (I think they are dependencies that npm handles by itself in a globally way but now it's adding them to my project locally, but I'm not sure).
Why am I getting all those unknown (for me) dependencies?
Notice that, when I run ember new it generates the correct dependencies in node_modules but if I delete this folder and run npm install happens the same.
That's one of the changes introduced by npm v3.0:
Your dependencies will now be installed flat - by default. If
possible, all of your dependencies, and their dependencies, and their
dependencies will be installed in your project's node_modules folder
without nesting. Nesting will only occur when two or more modules have
conflicting dependencies.
Read more at http://www.felixrieseberg.com/npm-v3-is-out-and-its-a-really-big-deal-for-windows/
I've installed NVM for node.js using the instructions from this post:
http://www.backdrifter.com/2011/02/18/using-nvm-and-npm-to-manage-node-js/
When I switch between node versions and then use npm to install a module, all the modules are placed in the same 'node_modules' folder (~/node_modules/) instead of in the 'node_modules' directory specific to that version of node?
Any idea on how to remedy this?
Based on the comments from https://github.com/creationix/nvm/pull/97:
When installing packages with npm using the global switch -g the
package ends up in the proper directory (i.e.
.nvm/$VERSION/lib/node_modules), however node is unable to require it
since it somehow isn't searching on it's prefix.
So using npm install -g xxxxx will put the modules in the correct location for NVM but if you try to require one of them node can't find the module. I am still playing around with this and will update if I find a solution.
Update
Where does NPM put node_modules? (see https://docs.npmjs.com/files/folders)
Local install (default): puts stuff in ./node_modules of the current package root.
Global install (with -g): puts stuff in /usr/local or wherever node is installed.
Install it locally if you're going to require() it.
Install it globally if you're going to run it on the command line.
If you need both, then install it in both places, or use npm link.
So what I did was run npm init (see http://npmjs.org/doc/init.html) in my projects root dir which generated package.json. Now when I run npm install xxxxx it creates a node_modules dir in my project folder (which I add to my .gitignore). This works for modules that I require in my code.
For commands such as CoffeeScript I install with npm install -g coffee-script which puts it in the correct directory (.nvm/$VERSION/lib/node_modules). While I can't require these modules (npm link should solve this problem) I can run the commands - i.e. coffee.
I just installed express globally (-g) and was having problem when require("express"). Just like Jesse Vogt said I just reinstalled express but this time without the -g just like this: "sudo npm install express" and now is working perfectly!
For latest nvm window version 1.1.7.
Package was installed and placed into the respective nodejs version.
nvm use 16.8.0
npm install truffle
nvm use 16.7.0
npm install mysql