Understand and fix Javascript & TypeScript bugs faster
npm install node-ray
The package can be installed in any NodeJS, ES6+, or TypeScript application to send data to the Ray app.
Install with npm:
``bash`
npm install node-ray
or bun:
`bash`
bun add node-ray
- Node.js >= 20.19
- ESM-only (CommonJS is no longer supported; use v2.x for require support)
node-ray offers several options to allow you to use it in either NodeJS, Web-based TypeScript or JavaScript projects, and browser environments.
> If you're using NextJs/React, take a look at permafrost-dev/react-ray.
>
> If you're using Vue, check out permafrost-dev/vue-ray.
When using in a NodeJS environment (the default), import the package as you would normally:
`js`
// es module import:
import { ray } from 'node-ray';
node-ray is ESM-only. CommonJS require is not supported.
When bundling scripts for use in a Browser environment _(i.e., using webpack or vite)_, import the /web export:
`js`
import { ray } from 'node-ray/web';
There are two standalone versions of node-ray available: one with axios included, and one without _(slim version)_.
node-ray may be directly used within a web page via a script tag. The standalone version includes all required libraries, including axios.
`html`
Or use the slim version _(without axios)_ if you already have axios included in your project:
`html`
#### Recommended Standalone Initialization
As of version 2.0.0, you no longer need to manually initialize the global ray objects; it is now performed automatically on load:
`html`
To use node-ray with Laravel Mix, include the following in resources/js/bootstrap.js:
`js
import { ray } from 'node-ray/web';
window.ray = ray;
`
Compile the bundle _(npm run dev)_as usual. After including js/app.js in your view, you may access ray() within your scripts.
To use node-ray with Laravel + Vite, include the following in resources/js/bootstrap.js:
`js
import { ray } from 'node-ray/web';
window.ray = ray;
`
ray() is immediately available to other scripts such as app.js, however note that window.ray() is NOT immediately available in