"Anything that can go wrong will go wrong" - Murphy's Law
Looks like someone hasn't follows the installation instructions correctly...
node-gyp (used to build better-sqlite3) is not compatible with Python 3. Yes, it's been 10 years since 3's release. Yes, it sucks. But you need to have python 2.7.x in your path to install better-sqlite3. If you're not using python anywhere else, uninstall it and make sure to follow my installation instructions. If you are, run npm config set python python2.7
before running the install again.
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. Stilll, 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 ^_^.
In order to install Enmap, you'll need a few things installed on your machine. First off, you need NodeJS (Node 10 is required. Not 8, not 9, not 12. NODE 10 ONLY). For Windows and MacOS, simply download and install from the website. For Linux, see this page for installation.
To install Enmap in your project, all you need to do is run the following command:
This may take a few minutes, then you're ready to use it.
For persistence you need to also install better-sqlite-pool
, which is necessary for the sqlite database interaction.
better-sqlite-pool
has a specific pre-requisite which is needed to build it. How to install these depends on your operating system, so see below for instructions:
On Windows, two things are required to install enmap-sqlite. Python 2.7 and the Visual Studio C++ Build Tools. They are required for any module that is built on the system, which includes sqlite.
The Windows Build Tools require over 3GB of space to install and use. Make sure you have enough space before starting this download and install!
To install the necessary pre-requisites on Windows, the easiest is to simply run the following command, 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, simply run the following command:
This will take a few minutes also, as it needs to build the module from source code.