Search code examples
javascriptnpm-scriptsnpm-build

I encountered a problem while doing Npm build in vanilla js. Please take a look


I was learning JavaScript and kind of ran into problem that said like this : Error Image

Here's my package.json enter image description here

So to explain, this is my vanilla js where i have installed parcel

Vs code Terminal

  • npm i parcel --save-dev
  • npm run start
  • npm run build

theen this error pops up. I don't know if i added enough screenshots or details to make someone understand my problem. If you do have a solution help please.

Edit : I also tried,

"main" : "17th.html" as suggested which then threw new error saying the extension should be of .js

Final edit : So , i deleted "main" and then it worked like a charm. Dont know why it works but it works . If someone could explain why it works then i would be very grateful.

I was expeccting a successful build


Solution

  • I had the same issue, what worked for me was just deleting

    main: "filepath"
    

    You can also organize this better by having a src folder and moving all your html files there, a js folder which contains all your js files and a css folder that contains all your css files.

    Below is my paackage.json which builds as intended.

    {
      "name": "something",
      "version": "1.0.0",
      "description": "stackoverflow example",
      "scripts": {
        "dev": "parcel src/index.html",
        "build": "parcel build src/index.html"
      },
      "author": "my name",
      "license": "ISC",
      "devDependencies": {
        "@parcel/transformer-sass": "^2.6.2",
        "parcel": "^2.6.2"
      },
      "dependencies": {
        "gsap": "npm:@gsap/shockingly@^3.10.4"
      }
    }