skip to Main Content

I tried adding node seedApp.ts in here before it tries to run my React app but I get Cannot use import statement outside a module

"web-dev-test-manually": "NODE_ENV=localApp node seedApp.ts && yarn lint && yarn copyData && yarn compile-server && yarn start-static-server & node_modules/.bin/webpack-dev-server -d --watch",

seedApp.ts

import { setupDatabase } from '../Database/SeedApp';

(async () => {
    await setupDatabase(['appdev/seed.companies.sql', 'appdev/seed.crafters.sql']);
})();

2

Answers


  1. Try using require instead of import:

    const { setupDatabase } = require('../Database/SeedApp');
    
    (async () => {
        await setupDatabase(['appdev/seed.companies.sql', 'appdev/seed.crafters.sql']);
    })();
    
    
    Login or Signup to reply.
  2. You can add node seedApp.ts before your start script in package.json
    For example, something like this should work.

    "scripts": {
      "start": "node start.js && react-scripts start"
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search