Installation
Please follow the installation guide first, when adding a new application to AppSignal.
Requirements
Before you can compile the AppSignal package, make sure the build/compilation tools are installed for your system. Please check the Supported Operating Systems page for any system dependencies that may be required.
Installation
First, sign up for an AppSignal account. Then, install AppSignal by adding @appsignal/nodejs
to your package.json
on the command line with npm
:
It's also possible to manually add the @appsignal/nodejs
package to your package.json
. Then, run npm install
.
Create an appsignal.cjs
file to require and configure AppSignal. This file may also be placed in another location, like in the src/
directory. For more information about the configuration, see our configuration section.
Requiring the AppSignal client
Now, you can run your application like you normally would, but use the --require
flag to load AppSignal's instrumentation before any other library:
We recommend adding the --require
flag to any script that starts your app:
You can also use the --require
flag with tools such as ts-node
and nodemon
.
When using a wrapper CLI, such as nest start
or fastify start
, to start your application, use the NODE_OPTIONS
environment variable to pass the flag to the Node.js runtime:
TypeScript support
AppSignal is fully compatible with TypeScript. When running a compiled TypeScript application with node
, we recommend using the --enable-source-maps
Node.js flag so that error backtraces in AppSignal refer to locations in the original TypeScript code:
When using a wrapper CLI, such as nest start
or fastify start
, to start your application, use the NODE_OPTIONS
environment variable to pass the flag to the Node.js runtime:
Import AppSignal Client
The AppSignal client is accessed from the globally exported Appsignal.client
object.
To use features like custom metrics, you must first import the AppSignal client:
Adding integrations
AppSignal supports several libraries and frameworks with additional packages, such as Express, Koa, Next.js and more. Additional installation instructions for these packages can be found in the Node.js integrations section.
Uninstalling AppSignal for Node.js
Uninstall AppSignal from your app by following the steps below. When these steps are completed your app will no longer send data to the AppSignal servers.
-
Run
npm uninstall @appsignal/nodejs
to uninstall the AppSignal for Node.js integration, or delete the line within thedependencies
block of your application'spackage.json
file referencing the@appsignal/nodejs
package. -
Run
npm install
to update yourpackage.lock
with the removed packages state. -
Remove any AppSignal configuration from your app.
-
Commit, deploy and restart your app.
- This will make sure the AppSignal servers won't continue to receive data from your app.
-
Finally, remove the app on AppSignal.com.
Stopping The AppSignal Client
AppSignal will stop automatically when your application or machine stops running. However, if you want to stop AppSignal manually you can run the following command: