Using node modules
Corteza Corredor supports the use of external node modules, both on the server-scripts and client-scripts.
Corteza Corredor uses the Yarn package manager. |
-
manually insert it into the
package.json
file, -
run the
yarn add NAME_GOES_HERE
.
When you register and load the extension in the Corredor server, it will automatically resolve any changed dependency from the package.json
file.
We’re observing some anomalies when running Yarn inside a docker container. If you’re getting an error message similar to the one below, it means that Yarn was not able to install the dependencies. This error occurs when Yarn is unable to store its cache.
To fix this, you need to:
The dependencies should now be installed and available for use.
The above |
Node modules can then be used just like anywhere else.
{
"dependencies": {
"axios": "^0.18.0"
}
}
import axios from 'axios'
export default {
// ...
async exec() {
await axios.get(...)
// ...
}
}
Different extensions do not share their dependencies. If two extensions use the same dependency, they both need to define it. |