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

parcel serve fails on 2.8.3 but works fine on 2.7.0 #8782

Closed
maxcan opened this issue Jan 22, 2023 · 15 comments · Fixed by #8788
Closed

parcel serve fails on 2.8.3 but works fine on 2.7.0 #8782

maxcan opened this issue Jan 22, 2023 · 15 comments · Fixed by #8788

Comments

@maxcan
Copy link

maxcan commented Jan 22, 2023

🐛 bug report

Trying to build a simple React / TypeScript project. On parcel 2.7.0, parcel serve and parcel build both run fine. On 2.8.3, parcel build runs fine but parcel serve runs into this error:

🚨 Build failed.

@parcel/core: Failed to resolve 'process' from './node_modules/.pnpm/react-error-overlay@6.0.9/node_modules/react-error-overlay/lib/index.js'

  /Users/max/development/jamax/node_modules/.pnpm/react-error-overlay@6.0.9/node_modules/react-error-overlay/lib/index.js:1:4450
  > 1 | s[o]:process.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,t="/"===a.charAt(0))}return(t?"/":"")+(e=r(n(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."},t.normalize=fu
  >   |      ^^^^^^^

@parcel/resolver-default: Node builtin polyfill "process/" is not installed, but auto install is disabled.

  /Users/max/development/jamax/node_modules/.pnpm/react-error-overlay@6.0.9/node_modules/react-error-overlay/lib/index.js:1:4450
  > 1 | s[o]:process.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,t="/"===a.charAt(0))}return(t?"/":"")+(e=r(n(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."},t.normalize=fu
  >   |      ^^^^^^^ used here

  💡 Install the "process/" package with your package manager, and run Parcel again.
  📝 Learn more: https://parceljs.org/features/node-emulation/#polyfilling-%26-excluding-builtin-node-modules

None of the workarounds in #7697 or #7060 seem to work. Also, I've tried enabling autoinstall and get a similar erorr:

🚨 Build failed.

@parcel/core: Failed to resolve 'process' from './node_modules/.pnpm/react-error-overlay@6.0.9/node_modules/react-error-overlay/lib/index.js'

  /Users/max/development/jamax/node_modules/.pnpm/react-error-overlay@6.0.9/node_modules/react-error-overlay/lib/index.js:1:4450
  > 1 | s[o]:process.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,t="/"===a.charAt(0))}return(t?"/":"")+(e=r(n(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."},t.normalize=fu
  >   |      ^^^^^^^

@parcel/resolver-default: Failed to install process: pnpm failed to install modules

  Error: Failed to install process: pnpm failed to install modules
      at $32ea97b83cf5d752$var$install (/Users/max/development/jamax/node_modules/.pnpm/@parcel+package-manager@2.8.3_@parcel+core@2.8.3/node_modules/@parcel/package-manager/lib/index.js:3690:15)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async $b0fd219fea43bcac$export$2e2bcd8739ae039._runFn (/Users/max/development/jamax/node_modules/.pnpm/@parcel+utils@2.8.3/node_modules/@parcel/utils/lib/index.js:33579:13)
      at async $b0fd219fea43bcac$export$2e2bcd8739ae039._next (/Users/max/development/jamax/node_modules/.pnpm/@parcel+utils@2.8.3/node_modules/@parcel/utils/lib/index.js:33572:9)

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

broken package.json on 2.8.3

{
  "name": "users-react",
  "version": "1.0.0",
  "source": "src/index.html",
  "private": true,
  "scripts": {
    "start": "parcel",
    "build": "parcel build"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": "> 0.5%, last 2 versions, not dead",
  "devDependencies": {
    "@parcel/config-default": "^2.8.3",
    "@parcel/core": "^2.8.3",
    "@parcel/transformer-typescript-tsc": "^2.8.3",
    "@tailwindcss/forms": "^0.5.3",
    "@tailwindcss/typography": "^0.5.9",
    "@types/js-cookie": "^3.0.2",
    "@types/luxon": "^3.2.0",
    "@types/mixpanel-browser": "^2.38.0",
    "@types/react": "^18.0.27",
    "@types/react-dom": "^18.0.10",
    "@typescript-eslint/eslint-plugin": "^5.48.2",
    "@typescript-eslint/parser": "^5.48.2",
    "autoprefixer": "^10.4.13",
    "daisyui": "^2.47.0",
    "eslint": "^8.32.0",
    "parcel": "^2.8.3",
    "parcel-reporter-static-files-copy": "^1.5.0",
    "postcss": "^8.4.21",
    "tailwindcss": "^3.2.4",
    "typescript": "^4.9.4"
  },
  "@parcel/transformer-js": {
    "inlineEnvironment": [
      "REACT_APP_*",
      "NODE_ENV"
    ]
  },
  "alias": {
    "process": false
  },
  "targets": {
    "main": {
      "context": "browser"
    }
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.2.1",
    "@fortawesome/free-brands-svg-icons": "^6.2.1",
    "@fortawesome/free-regular-svg-icons": "^6.2.1",
    "@fortawesome/free-solid-svg-icons": "^6.2.1",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@hookform/devtools": "^4.3.0",
    "@rpldy/upload-button": "^1.3.1",
    "@rpldy/uploady": "^1.3.1",
    "clsx": "^1.2.1",
    "js-cookie": "^3.0.1",
    "localforage": "^1.10.0",
    "luxon": "^3.2.1",
    "match-sorter": "^6.3.1",
    "mixpanel-browser": "^2.45.0",
    "process": "^0.11.10",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-hook-form": "^7.42.1",
    "react-router-dom": "^6.7.0",
    "react-router-typesafe-routes": "^0.5.1",
    "shared": "workspace:^1.0.0",
    "sort-by": "^1.2.0"
  }
}

working package.json on 2.7.0

{
  "name": "users-react",
  "version": "1.0.0",
  "source": "src/index.html",
  "private": true,
  "scripts": {
    "start": "parcel",
    "build": "parcel build"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": "> 0.5%, last 2 versions, not dead",
  "devDependencies": {
    "@parcel/config-default": "~2.7.0",
    "@parcel/core": "~2.7.0",
    "@parcel/transformer-typescript-tsc": "~2.7.0",
    "@tailwindcss/forms": "^0.5.3",
    "@tailwindcss/typography": "^0.5.9",
    "@types/js-cookie": "^3.0.2",
    "@types/luxon": "^3.2.0",
    "@types/mixpanel-browser": "^2.38.0",
    "@types/react": "^18.0.27",
    "@types/react-dom": "^18.0.10",
    "@typescript-eslint/eslint-plugin": "^5.48.2",
    "@typescript-eslint/parser": "^5.48.2",
    "autoprefixer": "^10.4.13",
    "daisyui": "^2.47.0",
    "eslint": "^8.32.0",
    "parcel": "~2.7.0",
    "parcel-reporter-static-files-copy": "^1.5.0",
    "postcss": "^8.4.21",
    "tailwindcss": "^3.2.4",
    "typescript": "^4.9.4"
  },
  "@parcel/transformer-js": {
    "inlineEnvironment": [
      "REACT_APP_*",
      "NODE_ENV"
    ]
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^6.2.1",
    "@fortawesome/free-brands-svg-icons": "^6.2.1",
    "@fortawesome/free-regular-svg-icons": "^6.2.1",
    "@fortawesome/free-solid-svg-icons": "^6.2.1",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@hookform/devtools": "^4.3.0",
    "@rpldy/upload-button": "^1.3.1",
    "@rpldy/uploady": "^1.3.1",
    "clsx": "^1.2.1",
    "js-cookie": "^3.0.1",
    "localforage": "^1.10.0",
    "luxon": "^3.2.1",
    "match-sorter": "^6.3.1",
    "mixpanel-browser": "^2.45.0",
    "process": "^0.11.10",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-hook-form": "^7.42.1",
    "react-router-dom": "^6.7.0",
    "react-router-typesafe-routes": "^0.5.1",
    "shared": "workspace:^1.0.0",
    "sort-by": "^1.2.0"
  }
}

🤔 Expected Behavior

parcel serve should successfully run in 2.8.3 as it does in 2.7.0

😯 Current Behavior

parcel serve does not successfully run in 2.8.3 as it does in 2.7.0

💁 Possible Solution

downgrade to 2.7.0

🔦 Context

forces me to stay on an old version.

💻 Code Sample

🌍 Your Environment

Software Version(s)
Parcel 2.7.0 / 2.8.3
Node 16.19.0
pnpm 7.22
Operating System OSX / ARM
@devongovett
Copy link
Member

Did you try installing "process" manually?

@maxcan
Copy link
Author

maxcan commented Jan 22, 2023

yes, via pnpm: pnpm add process

@unownone
Copy link

@maxcan having the same issue.

@mischnic
Copy link
Member

Are both of you using pnpm workspaces? These Node polyfills have to be installed in the root of the workspace

@unownone
Copy link

I am getting a different error actually, should have lead with that . But it is in the same ballpark basically:

PS D:\Coding\Clubs\phoenix\phoenix-react-app> yarn start
Server running at http://localhost:3000

@parcel/resolver-default: Auto installing polyfill for Node builtin module "process"...

  D:\Coding\Clubs\phoenix\phoenix-react-app\.yarn\cache\react-error-overlay-npm-6.0.9-96e7e1e53a-695853bc88.zip\node_modules\react-error-overlay\lib\index.js:1:44
50
  > 1 | s[o]:process.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(e=a+"/"+e,t="/"===a.charAt(0))}return(t?"/":
  >   |      ^^^^^^^ used here

  � Learn more: https://parceljs.org/features/node-emulation/#polyfilling-%26-excluding-builtin-node-modules

✨ Built in 935ms

I have tried :

  • downgrading to 2.7.0 - didnt work
  • trying fixes from the learn more link - didnt work
  • adding more configs, installing process using yarn 3.3.0 - didnt work either

The build comes out to be blank as nothing renders / console.log() too.

@unownone
Copy link

Are both of you using pnpm workspaces? These Node polyfills have to be installed in the root of the workspace

does yarn use pnpm ? @mischnic

@mischnic
Copy link
Member

mischnic commented Jan 22, 2023

Any kind of workspace feature (doesn't matter if it's npm, Yarn, pnpm), where you have multiple local packages with a single lockfile

@unownone
Copy link

Any kind of workspace feature (doesn't matter if it's npm, Yarn, pnpm), where you have multiple local packages with a single lockfile

Then yeah I guess. How do I do this :

These Node polyfills have to be installed in the root of the workspace

@mischnic
Copy link
Member

run yarn add -D process (or yarn add -WD process) in the folder that contains the package.json with "workspaces": ["app, "shared"]

@unownone
Copy link

run yarn add -D process (or yarn add -WD process) in the folder that contains the package.json with "workspaces": ["app, "shared"]

The error still persists.

@maxcan
Copy link
Author

maxcan commented Jan 22, 2023

Are both of you using pnpm workspaces? These Node polyfills have to be installed in the root of the workspace

@mischnic I'm not sure what this means in the context of pnpm. Unlike yarn, pnpm doesn't really have a "root" workspace but more just a cache of packages where each package is hard linked to the node_modules directory of any package that imports it. As far as any individual package can tell, it is no different from being a standalone npm package.

Also, for me this only comes up with parcel serve on 2.8.3 and not parcel build in that version of either command in 2.7.0.

@mellodev
Copy link

Hi @maxcan I am researching other gh issues to see if I can find a fix for a build/serve issue that I'm having after updating to 2.8.3. I'm wondering if you are able to build/serve from 2.8.2 ok?

@maxcan
Copy link
Author

maxcan commented Jan 24, 2023

@mellodev, I just confirmed the same errors on 2.8.0, 2.8.1, and 2.8.2. 2.7.0 is the only one that seems to work for me. I haven't gone earlier than that though.

@mischnic
Copy link
Member

mischnic commented Jan 24, 2023

-> #8788 (but since it's only the autoinstall that's broken, adding process manually as a dependency to the root should fix it as well)

What I mean by root is the folder containing pnpm-workspace.yaml (and the lockfile, I assume?).
The folder containing a lockfile, or .git is viewed by Parcel as the project root. And Node builtin polyfills (such as process) are resolved from that folder (and therefore also autoinstalled into that folder).

@maxcan
Copy link
Author

maxcan commented Jan 24, 2023

@mischnic I was having trouble installing the packages off the branch but I gave up and created a top level package.json to install process. Its not what I'd prefer, but it works so I'm happy.

Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants