共用方式為


Node application on Azure Web Apps gets runtime error on loading module Sqlite3

 

After a node application was deployed to Azure App Service Web Apps (Websites), the application threw an error at starting.

Node looked for:

"D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\node-v14-win32-ia32\node_sqlite3.node"

While NPM installed it at:

"D:\home\site\wwwroot\node_modules\sqlite3\lib\binding\node-v11-win32-ia32\node_sqlite3.node"

Troubleshooting

The path template can be found in sqlite3\package.js

  "binary": {

    "module_name": "node_sqlite3",

    "module_path": "./lib/binding/{node_abi}-{platform}-{arch}",

    "host": "https://mapbox-node-binary.s3.amazonaws.com",

    "remote_path": "./{name}/v{version}/{toolset}/",

    "package_name": "{node_abi}-{platform}-{arch}.tar.gz"

  },

The issue could happen when the node that deploys the SQLite3 module, is a different version from the version of node that runs the application.

Module installation

When "NPM install" was run to deploy the node application to worker instances, node was loaded from D:\Program Files (x86)\nodejs\0.10.32\

This node's version was 0.10.32, whose node_adi value was "node-v11". That's why the sqlite3 module was installed to node-v11-win32-ia32

This default version is controlled by an app setting available on the management portal. It is 0.10.32 at the moment.

clip_image001

The %PATH% environment is rendered according to this setting.

clip_image003

Application launch

The node version used to launch the application can be controlled by application's package.json file

"engines": {

"node": "0.12.0"

},

Best practice

It's a best practice to sync up the version in package.json with the one on the management portal.

Azure doesn't update the default version immediately after making the latest node version available on worker instances. One reason is to not break the existing node application that were deployed by history node versions.

As a workaround, we could hard code the path in Sqlite3's package.js file.

Regards,

Juntao Zhu from APAC DSI Team