Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "engines" attribute to package.json causes "External modules are not supported" error #7636

Closed
marvingreenberg opened this issue Feb 1, 2022 · 1 comment

Comments

@marvingreenberg
Copy link

🐛 bug report

See #6769
External modules are not supported when building for browser.

There are various reasons to specify the required node engine for development, such as tool chain requirements. Specifying "engines" should not affect the ability to target the browser.

🎛 Configuration (.babelrc, package.json, cli command)

With engines removed parcel build ./src/index.html works, with it present, fails with
@parcel/packager-js: External modules are not supported when building for browser

{
    "version": "0.0.1",
    "name": "console-framework-poc",
    "description": "POC for Console UI",
    "dependencies": {
        "react": "^17.0.2",
        "react-dom": "^17.0.2"
    },
    "engines": { "node": ">=14.0" },
    "devDependencies": {
        "@1uphealth/eslint-config": "^0.1.1",
        "@types/express": "^4.17.13",
        "@types/node": "^14.18.9",
        "@types/react": "^17.0.38",
        "@types/react-dom": "^17.0.11",
        "@typescript-eslint/eslint-plugin": "^4.33.0",
        "eslint": "^7.32.0",
        "eslint-plugin-chai-friendly": "^0.7.2",
        "eslint-plugin-import": "^2.25.4",
        "eslint-plugin-jest": "^24.7.0",
        "eslint-plugin-jsx-a11y": "^6.5.1",
        "eslint-plugin-mocha": "^9.0.0",
        "eslint-plugin-no-async-foreach": "^0.1.1",
        "eslint-plugin-prettier": "^4.0.0",
        "eslint-plugin-promise": "^5.2.0",
        "eslint-plugin-react": "^7.28.0",
        "eslint-plugin-react-hooks": "^4.3.0",
        "eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
        "eslint-plugin-unicorn": "^36.0.0",
        "parcel": "^2.2.1",
        "prettier": "^2.5.1",
        "typescript": "^4.5.5"
    },
    "scripts": {
        "build": "parcel build ./src/index.html",
        "start": "parcel ./src/index.html"
    }
}
{
  "your": { "config": "here" }
}

🤔 Expected Behavior

Presence of "engines" in package.json should not affect the build

😯 Current Behavior

💁 Possible Solution

🔦 Context

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 2.2.1
Node 14.8.1
npm/Yarn npm 6.14
Operating System MacOS 11.6.2
@mischnic
Copy link
Member

mischnic commented Mar 4, 2022

For the majority of projects, the detection of engines.node to bundle for Node works well, but as you've noticed not for everybody.

You need to do

  "engines": {
    "node": ">=14.0"
  },
  "targets": {
    "default": {
      "engines": {
        "browsers": ">= 50%"
      }
    }
  }

We should note this in the docs somehow: parcel-bundler/website#1008

@mischnic mischnic closed this as completed Mar 4, 2022
vgeorge added a commit to developmentseed/project-seed that referenced this issue May 30, 2022
Luna0788 added a commit to Luna0788/middle.messenger.praktikum.yandex that referenced this issue Aug 22, 2022
gao-sun added a commit to logto-io/logto that referenced this issue Nov 7, 2022
david-mears-2 added a commit to david-mears-2/tf-scenario-generator that referenced this issue Dec 7, 2022
pklaschka added a commit to wuespace/telestion-client that referenced this issue Dec 26, 2022
…el build errors

Before, while `parcel` (i.e., serving the page) worked without issues, in `parcel build`, the resulting files (if any were generated at all) wouldn't work because of an error saying "External modules are not supported".

Refs: parcel-bundler/parcel#7636
fussel178 pushed a commit to wuespace/telestion-client that referenced this issue Dec 26, 2022
…el build errors

Before, while `parcel` (i.e., serving the page) worked without issues, in `parcel build`, the resulting files (if any were generated at all) wouldn't work because of an error saying "External modules are not supported".

Refs: parcel-bundler/parcel#7636
ccamel added a commit to ccamel/playground-elm that referenced this issue Aug 14, 2023
ccamel added a commit to ccamel/playground-elm that referenced this issue Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants