To install Enmap, please read these instructions very carefully, every word is important!
Enmap is a wrapper around better-sqlite3, which requires to be built directly on your system. As such, you need to install pre-requisites first. Please follow these instructions to the letter. If it's not written here, you probably shouldn't do it unless you know why you're doing it.
SQLite modules usually only successfully work on LTS versions of node. This means it will work correctly on node 12, and 14. It will not work on node 13, 15, 17. Make sure you have the right version, check this with node -v
.
Also, better-sqlite3 doesn't compile on unreleased node versions usually. Your mileage may vary, but don't expect it to work on the "Latest" version of node either.
How to install the pre-requisites depends on your operating system, so see below for instructions:
On Windows, two things are required to install better-sqlite3. Python, and the Visual Studio C++ Build Tools. They are required for any module that is built on the system, which includes sqlite.
To install the necessary prerequisites on Windows, the easiest is to simply run the following commands separately, under an administrative command prompt or powershell:
It's very important that this be run in the administrative prompt, and not a regular one.
Once the windows-build-tools are installed (this might take quite some time, depending on your internet connection), close all open command prompts, powershell windows, and editors with a built-in console/prompt. Otherwise, the next command will not work.
On Linux, the pre-requisites are much simpler in a way. A lot of modern systems (such as Ubuntu, since 16.04) already come with python 2.7 pre-installed. For some other systems, you might have to fiddle with it to either get python 2.7 installed, or to install both 2.7 and 3.x simultaneously. Google will be your friend.
As for the C++ build tools, that's installed using the simple command: sudo apt-get install build-essential
for most debian-based systems. For others, look towards your package manager and specificall "GCC build tools". Your mileage may vary but hey, you're using Linux, you should know this stuff.
As of writing this page, MacOS versions seem to all come pre-built with Python 2.7 on the system. You will, however, need the C++ build tools.
Install XCode
Once XCode is installed, go to Preferences, Downloads, and install the Command Line Tools.
Once installed, you're ready to continue.
Once those pre-requisites are installed (if they're not, scroll up, and follow the instructions), and you've closed all open command prompts, open a new, normal (not-admin) command prompt or terminal in your project, then install Enmap using the following command:
This will take a few minutes, as it needs to build better-sqlite3 from source code, and then install enmap itself. Note that "a few minutes" can be 1 or 30 minutes, it really depends on your hardware and configuration.
If you get any errors, please see the Troubleshooting Guide. If the guide doesn't help, join the Discord (link at the top of this page).
This guide assists in migrating your data from Enmap 3 using Providers, to the latest version of enmap.
You do not need this page if you're new to Enmap or if you're starting a new project!
Upgrading to enmap v4 requires a little bit of migration, as Enmap 4 changed the internal method by which data is stored, slightly. To use this migration:
Make a copy of your current app in a new folder.
Create a new folder "on the same level" as your bot. Name it something like "migrate"
You should now have 3 folders. Something like mybots/coolbot
, mybots/coolbot-copy
, mybots/migrate/
In the migrate
folder, run npm i enmap@3.1.4 enmap-sqlite@latest
, as well as whatever source provider you need if it's not sqlite (in my example, npm i enmap-mongo@latest
You should now have something like the following image.
In the migrate
folder, create an index.js
and use the following script for migration. Note that it's an example, change the provider option to fit what you're actually using.
Very important: the "target" must be enmap-sqlite. Enmap v4 only supports an sqlite-backend.
From the migrate
folder, run node index.js
, which should correctly migrate your data.
If you're using enmap-sqlite already, you don't really need to do the entire thing above. Adding a single file called migrate.js
to your project folder, then running it with node migrate.js
will convert the format and then all you need is to modify the code for Enmap 4. Still, I recommend backing up your bot first. Just in case.
There is very little you need to change when moving to Enmap 4. The only changes that are required after migrating is the initialization of your Enmap which is now simpler.
If using Enmap.multi(), the change is just as simple:
The rest of your code (all interactions with Enmap) can remain the same - there should be no need to edit any of it.
Once your data is migrating and the code is changed, you can go ahead and install enmap version 4 through npm i enmap@latest
in your "new" bot folder (the target of the migration). This will take a few minutes (it needs to rebuild sqlite) and output that 4.0.x is now installed. Start the bot, and it should be working! If it doesn't, join the support server and we'll help you out ^_^.
"Anything that can go wrong will go wrong" - Murphy's Law
Please make sure to read the install page VERY CAREFULLY! This should solve all the issues you face. If not carry on, but don't say we didn't tell you.
Your computer has to install some programs and then build everything from source. This is going to take a while depending on your computer speed. Patience is key. We can't speed it up for you. It may look like its frozen but it is not.
Please make sure you read the install page first. If you can't find what your looking for you can join the discord here.
Looks like someone hasn't follows the installation instructions correctly...