Editor and NPM
npm is ideally suited for distribution of open source software such as DataTables, but it doesn't work so well for commercial software such as Editor. The full Editor package is only available to license holders, a license which npm knows nothing about. The source for Editor could be placed on npm for distribution but there would be no way to enforce the license - and the license fees from Editor is what makes continued development and support of DataTables and its other extensions possible!
The approach taken to allow Editor to be used in an npm tool chain is to have an almost empty holding package on npm which will be installed when
npm install datatables.net-editor is executed. This has a post-install script which will display an information message detailing how the full Editor package can be installed:
# npm install datatables.net-editor
> node postinstall.js
DataTables Editor installation
To complete the installation of Editor, please download a licensed or trial package from
https://editor.datatables.net/download and then run the install.js script:
node node_modules/datatables.net-editor/install.js path/to/Editor.zip
This will insert the correct licensed or trial files into your node_modules structure.
To complete the installation download Editor (either the licensed version or the trial) and then execute the
node_modules/datatables.net-editor/install.js script, pointing it to the download Editor zip file, as detailed in the post-install message. The script will unzip the package and insert files into their required locations for use with
import editor from 'datatables.net-editor'; /
require('datatables.net-editor'); just like with any other package.
Just as with DataTables core and the other extensions, there are also packages for the styling frameworks supported by Editor such as Bootstrap, Foundation and Semantic UI. As with the other software, these styling integration libraries are defined by adding a suffix to the package such as
-bs for Bootstrap 3. Please see the npm download page for full details.
There is no additional installation script to run for the styling packages, the main installation script will automatically detect if there are any Editor styling packages installed and move the appropriate files from the Editor zip package into those packages.
For integration with source control, it is recommended that you commit the zip file into your repository, so the install command can be easily completed whenever
npm install is run for future clones of the project. Equally, a custom post install script could be used to execute the install command immediately. In this way you do not need to commit anything from
node_modules into source control.
Ideally this extra step wouldn't be required for installing Editor via npm. However, due to its commercial nature and requiring a license to being able to use it, I'm not aware of any better solutions. If anyone does has any suggestions for how this could be improves, they are very welcome. In the meantime, hopefully this post has described the what, why and how of using Editor with npm / yarn.