I need to set add-ons on my Flutter project, this is a Backend API using Node.JS which will serve as a middleman API for my Flutter project to retrieve and manage data from database in any platform (e.g., Android, iOS, Windows, and Web).
Now, my folder structure is,
backend-api/
|- config/
| |- db.config.js // initialize the connection to mssql
| |- sequelize.config.js //add sequelize structure with db.config.js
|- models/
| |- index.js // Sequelize setup and model definitions
| |- random.text.model.js // Example model definition
|- controllers/
| |- random.text.controller.js // CRUD with MSSQL stored procedure operations for random text
|- routes/
| |- random.text.routes.js // Routes for random text CRUD SP's operations
|- server.js //last setup which I will use later to add in my Flutter project to access my backend API
My problems are:
node:internal/modules/esm/resolve:265
throw new ERR_MODULE_NOT_FOUND(
^Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\userDir\Flutter\RandomText\backend-api\controllers\tutorial.controller.js' imported from C:\Users\userDir\Flutter\RandomText\backend-api\routes\random.text.routes.js
After I execute this command: node server.js
to run it locally and test my backend API.
I appreciate any help you can provide.
I've set the prerequisites for my backend API, and also I've already used my SQL Server credentials to my other project which will be my basis that it will work as expected. I need the Node.JS integration to my Flutter project to serves as a data access level (DAL).
I prevented myself to provide the code as it seems to be unnecessary, because I wondering for some developer who had encountered the same error. What I need is to assess the solution you have applied and shared to this forum.
Again, thank you.
I've already resolved it by identifying proper exports of variables from one class file to another. It was like exporting from where it was created and then importing it to where it should be used.
I've discovered that it was like creating my own packages within the project itself.
P.S., I am using Node.JS with Express.js. It was so fun to play around with.