I have a NodeJS server code written in JSX where I import a superant in this way:
import request from 'superagent';
When the server starts after the build, I get the following error: TypeError: require is not a function. And this happens on the following line in my compiled code:
var crypto = require('crypto');
When tracking backwards, I realized that cryptography is required "formidable", that a "super agent" is required.
I have the same superagent import in my client side javascript code, but it works great. I have decomposed JS compilation code for node (server) and client, and both of them are the same. Thus, this does not seem to be a problem with its construction.
Has anyone seen this error before and would you know what needs to be done?
source share