I’m on react, I have a file I need to run on a command like this
"runFunction": "npx ts-node ./src/seedParkStreetSalesData.js"
And this is the file
/* import { Op } from 'sequelize';
import { env } from './utils/envConfig';
import axios from 'axios';
import { convertRegExpression } from './helpers/sales';
import Territory from './models/territory.model';
import Product from './models/product.model';
import Sales from './models/sale.model';
*/
async function seedParkstreetSales() {
const { env } = require('./utils/envConfig.ts');
const { Op } = require('sequelize');
const axios = require('axios');
const { convertRegExpression } = require('./helpers/sales.ts');
const Territory = require('./models/territory.model.ts');
const Product = require('./models/product.model.ts');
const Sales = require('./models/sale.model.ts');
...
}
seedParkstreetSales()
But I’ve been getting errors in the imports because it either treats the imports as modules, and as such their own import statements return syntax errors, or the function doesn’t run at all. (I tried both ways of importing)
I tried using
"runFunction": "npx ts-node/esm ./src/seedParkStreetSalesData.js"
And the function doesn’t run at all. With the current command line I get this error
Error: Cannot find module ‘../utils/envConfig.js’
How can I import this files properly? I don’t want to rename them with mjs or cjs