complete-javascript-course
complete-javascript-course copied to clipboard
npm run Build Failed
While trying to bundle with parcel, i ran "npm run start" after assigning the "start" and "build" in the scripts inside the package.json but it gave an error with the following message:
Build failed.
@parcel/core: Unexpected output file type .html in target "main"
"description": "Reciepe App",
5 | "main": "index.html", | ^^^^^^^^^^^^ File extension must be .js, .mjs, or .cjs 6 | "scripts": { 7 | "start": "parcel index.html"
💡 The "main" field is meant for libraries. If you meant to output a .html file, either remove the "main" field or choose a different target name.
And when i tried removing the main and the index.html. It gives an error that "Browser scripts cannot have imports or exports."
You should remove this line "main": "index.html",
from you package.json file. NPM adds it by default to the package.json file on initial creation, and Parcel uses that "main"
field as the output path for libraries (source) which causes an error in this case because Forkify is a standalone project (not a library) with the Html file as an entry point.
To solve this error "Browser scripts cannot have imports or exports.", add type="module"
to the
<script type="module" src="src/js/controller.js"></script>
This change is needed because modules in Parcel@2 match the behavior of native modules (non-module files can't have imports and exports) (source).
Thanks akozdev, It now works. Thanks for taking your time to explain the details to me. i really appreciate it man. !
@mister-abdurahman You could deploy the app on the web ?