To use Node.js, create a file inside your project's api
directory. No additional configuration is needed.
The entry point for src
must be a glob matching .js
, .mjs
, or .ts
files that export a default function.
To disable helpers:
NODEJS_HELPERS
and the Value: 0
. You should ensure this is set for all environments you want to disable helpers for.For more information, see Environment Variables.
To install private npm modules:
NPM_TOKEN
and enter your npm token as the value. Alternatively, define NPM_RC
as an Environment Variable with the contents of ~/.npmrc
.For more information, see Environment Variables.
In some cases, you may wish to include build outputs inside your Vercel Function. To do this:
vercel-build
script within your package.json
file, in the same directory as your Vercel Function or any parent directory. The package.json
nearest to the Vercel Function will be preferred and used for both installing and building:{
"scripts": {
"vercel-build": "node ./build.js"
}
}
build.js
:const fs = require('fs');
fs.writeFile('built-time.js', `module.exports = '${new Date()}'`, (err) => {
if (err) throw err;
console.log('Build time file created successfully!');
});
.js
file for the built Vercel functions, index.js
inside the /api
directory:const BuiltTime = require('./built-time');
module.exports = (request, response) => {
response.setHeader('content-type', 'text/plain');
response.send(`
This Vercel Function was built at ${new Date(BuiltTime)}.
The current time is ${new Date()}
`);
};
When a SIGINT signal is sent to a Node.js function, it will terminate every function running on that Fluid instance. When implementing graceful shutdown patterns in your Node.js functions, keep this instance-wide termination behavior in mind.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4