Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

278
Views
Where should the path from main in package.json point to?

The package.json was created with the yarn cli. It fails when I try to build it. If I remove "main": "src/index.js" it works. src/index.js exists but it's an empty file for now.

Do I need to specify the path to my bundle or why does this throw an error? Changing the path to what is suggested in the error message doesn't work either.

package.json

{
  "name": "project",
  "version": "0.1.0",
  "description": "",
  "main": "src/index.js",
  "source": "src/index.html",
  "browserslist": "supports es6-module",
  "scripts": {
    "start": "parcel --open chrome",
    "build": "parcel build"
  },
  "repository": "",
  "author": "",
  "license": "MIT",
  "dependencies": {
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^3.4.0"
  },
  "devDependencies": {
    "parcel": "^2.0.0-rc.0"
  }
}

Output

$ parcel build
🚨 Build failed.

@parcel/namer-default: Target "main" declares an output file path of "src/index.js" which does not match the compiled bundle type "html".

  .../project/package.json:5:11
    4 |   "description": "project",
  > 5 |   "main": "src/index.js",
  >   |           ^^^^^^^^^^^^^^ Did you mean "src/index.html"?
    6 |   "source": "src/index.html",
    7 |   "scripts": {

  💡 Try changing the file extension of "main" in package.json.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The main field in package.json is intended to be used by library developers (e.g. if you are building a package that you intend to publish to npm to be consumed by others). In this context, it specifies the output target - i.e. where parcel should put an optimized commonjs javascript bundle. (see high-level documentation and detailed documentation).

In your case, it seems like you're building an app, not a library, so I would recommend just removing the main field entirely, which should resolve the errors you are seeing.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!