0

I was trying to change some unwanted automatic formatting in my VS-Code and seem to have broken my app. I was removing/reinstalling eslint and prettier. When I try to run my start script I get the following error:

./src/index.js
  Line 1:1:  Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

My index.js file looks like this:

enter image description here

I don't think I had this error before.

I've ran npx eslint --init and set up my eslintrc.json file as follows:

enter image description here

From what I've read, this line should have fixed it: "sourceType": "module", but it's not done so. I've tried uninstalling and reinstalling eslint, and I've tried restarting my computer.

JimmyTheCode
  • 3,783
  • 7
  • 29
  • 71
  • I think you can just say `import dotenv from 'dotenv';` and then you can use config by saying dotenv.config() – Norse Apr 06 '21 at 10:13
  • Thanks for the advice! I tried this and I still get the same error. It looks like the issue is the ```import React from 'react';```. It doesn't like ```import``` for some reason? – JimmyTheCode Apr 06 '21 at 10:19
  • Hmmm, maybe try writing `import * as React from 'react'`. Sometimes that works – Norse Apr 06 '21 at 10:20
  • Maybe this solves your question: https://stackoverflow.com/questions/36367656/eslint-sourcetype-mixture-of-script-and-module – Norse Apr 06 '21 at 10:23
  • 1
    Thanks Norse. I don't think that's the problem. My app was working for literally months until I started playing around with eslint, prettier, etc. I think there may be some residual config that I need to wipe/change. I just don't know where/how to find it. – JimmyTheCode Apr 06 '21 at 10:36

1 Answers1

0

So I've got things working again after I uninstalled VS Code and then reinstalled again.

It's weird because I'd tried uninstalling my eslint extension, but that didn't have any effect. I suspect I'd messed with some of my VS Code config items and that's what was breaking everything.

JimmyTheCode
  • 3,783
  • 7
  • 29
  • 71