Why do I need to install a compiler?
Some devops features such as monitoring and memory / CPU profiling require native (C++) code. StrongLoop distributes its software with npm, but npm compiles native code upon installation. Therefore, to take advantage of these features, you must install a compiler. If you don’t want these features, you may see error messages, but you should still be able install successfully.
If you don’t have a C++ compiler (Visual C++ on Windows or XCode on OSX) and associated command-line tools, you won’t be able to view most useful metrics, and you won’t be able to perform CPU profiling or take heap snapshots.
Important: If you don’t have compiler tools, when you run your application, you may see error messages such as “strong-agent could not load optional native add-on”.
To eliminate the error messages and enable monitoring and tracing features, install the appropriate C++ compiler and related tools as described below.
Configuring Python directory
Npm uses node-gyp to compile native modules, and node-gyp requires Python. If you installed Python in a non-standard directory, run this command to configure your setup:
$ npm config set python /path/to/python
/path/to/python is the directory where Python is installed.
For more information, see the node-gyp documentation.
Install the following:
- Python (v2.7.3 recommended, v3.x.x is not supported).
- Microsoft Visual Studio C++ 2013 (or later) for Windows Desktop. The Express version works well.
For Windows 7:
- For 64-bit builds of Node and native modules you will also need the Windows 7 64-bit SDK. If the install fails, try uninstalling any C++ 2010 x64&x86 Redistributable that you have installed first.
- If you get errors that the 64-bit compilers are not installed you may also need the compiler update for the Windows SDK 7.1.
npm uses Python 2.7 (not 3.x, and not 2.6.x or earlier) to install packages with compiled add-ons (such as strong-agent, or websocket support).
Download Python 2.7.x from http://python.org:
- Go to https://www.python.org/downloads/windows/
- Download latest stable 2.7.x Windows MSI Installer, either x86 or x86-64, as appropriate
- Run installer, and make sure to add to Path:
- Accept the default, Install for all users.
- Accept default “c:\Python27” for Python files.
- Enable the option Add python.exe to Path.
Visual Studio Community is free, and more than adequate to support Node.js.
Node.js does not support gcc, mingw, Cygwin, and other ports of non-Microsoft compilers to Windows.
npm uses Visual Studio 2012 or later to install packages with compiled add-ons (like strong-agent, or websocket support).
For Windows 7 and 8, use Microsoft Visual Studio 2015 (Community):
- Go to: https://www.visualstudio.com/downloads/download-visual-studio-vs
- Select “Download Community Free”, then download “vs_community_ENU.exe” , and next
If the download doesn’t start, click the Click here link, then on the next download page, click the Click here link beside vs_community_ENU.exe.
Run the installer, check “Visual C++” under “Programming Languages”, and accept the default location.
Note: This installation may take a long time.
- Apple Xcode.
- Depending on your version of MacOS and Xcode, you may need to also install the command-line tools. To install them in Xcode:
- Click Xcode > Preferences.
- Choose Downloads.
- Click the install button next to “Command-line Tools”.
Most versions of OSX come with Python by default. If for some reason you don’t have it, download and install Python.
Xcode license issues
If you see errors such as:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Then you recently upgraded or installed Xcode and haven’t agreed to the license yet.
Enter the following command to validate your Xcode license, then reinstall StrongLoop:
$ sudo xcode-select
Many Linux systems come with the necessary tools. The specific requirements are:
- Python (v2.7 recommended; v3.x.x is not supported). If you installed Python in a non-standard location, see Configuring Python directory.
- A proper C/C++ compiler toolchain, like GCC. NOTE: g– version 4.2 or later is required.
On Debian and Debian-derived distributions (Ubuntu, Mint, and so on), use the command:
$ apt-get install build-essential
Adding swap space
If during installation, you see the error message:
virtual memory exhausted: Cannot allocate memory
Then you need to add swap space so the compiler will have enough RAM. For example:
$ dd if=/dev/zero of=/swap bs=1M count=1024 $ mkswap /swap $ swapon /swap
After entering these commands, reinstall StrongLoop.
Note that the above command does not make the change permanent. When you reboot, you’ll need to re-run the
swapon /swap command if you want to reinstall or if your application uses binary add-ons.
For more information, see How To Configure Virtual Memory (Swap File) on a VPS.