Stripe API returns Cannot find module 'stripe'

Description

Manually fix stripe module not getting installed.

Discussion

The nodeJs modules AlphaAnywhere uses to integrate with services like stripe are installed just in time from zip files stored in a subfolder called 'node_install' under the executable folder.

The reason that NPM is not used to install these is to avoid the system dependencies (like reliance on a c/c++ compiler for node modules that include native code).

Earlier releases of AlphaAnywhere Pre-installed the node modules, but that was changed because it generally added 10 minutes to the installation process for modules that may or may not be used, and may of may not have changed from the prior release.

The modules are unzipped on the first request to the service to the AlphaAnywhere folder under ProgramData, which is where program specific data is stored - the folders beneath it are supposed to be writable, so that alpha anywhere can update them after installation.

The cause of this specific error has always been a change in permissions on the ProgramData folder, or a change in security, if the user that installed the program does not match the user running the program.

To manually perform the steps alpha anywhere does under the hood to install node modules you first need to get the Executable path and ProgramData path.

From the Alpha Anywhere interactive window, run the following code:

exe_path = a5.get_exe_path()
datafolder = A5_GetInstallationApplicationDataFolder(.t.)
sys_open(exe_path+"\node_install")
sys_open(datafolder+"\node")

This should open file explorer with the node_install folder (which contains the zip files), and the folder under which a writable node_modules folder should be.

Result of "sys_open(exe_path+"\node_install")"

images/node_install_folder.PNG

Result of "sys_open(datafolder+"\node")"

images/node_modules_folder.PNG

Under the program data node folder, you should see a folder called node_services, a file called node_service.js and a folder called node_modules, if this folder called node_modules does not exist, create it.

Change to the node_modules folder, you will notice that the stripe subfolder is missing, to fix this issue manually:

Clicked to navigate into node_modules.

images/inside_node_modules.PNG

Go to the node_install folder, copy the stripe.zip file into the node_modules folder.

Zip file pasted into node_modules location

images/copied_stripe_zip.PNG

Right click on the stripe.zip file in the node_modules folder, and Unzip it in place.

Menu displayed for right click on zip file

images/stripe_zip_rightclick.png

Extract all adds 'stripe' to the folder location / make sure you delete 'stripe' from the end of the path before you press the 'extract' button.

Extract Zip dialog / note that folder location has been edited to remove 'stripe'

images/stripe_zip_extract.PNG

If these steps worked, stripe should now run. If these steps failed - because the file did not copy due to a permissions issue, then you need to change to an account that has permission to write to these folders (like administrator) and try again.

You should see a new 'stripe' folder under node_modules if the stripe was successfully unzipped

images/stripe_unzipped.PNG

See Also