parcel: Build error with version 2.3.1: @parcel/core: Failed to resolve 'process' from ...
🐛 bug report
I just upgraded to version 2.3.1 and now the build process fails. Don’t know exactly if this is a parcel or a sentry issue?
🎛 Configuration (.babelrc, package.json, cli command)
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"useBuiltIns": false,
"targets": {
"node": "current"
}
}
],
"@babel/preset-react"
],
"plugins": [],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-modules-commonjs"]
}
}
}
🤔 Expected Behavior
Build should pass.
😯 Current Behavior
The build fails with the following exception:
🚨 Build failed.
@parcel/core: Failed to resolve 'process' from './node_modules/@sentry/utils/esm/node.js'
/Users/*****/Sites/*****/node_modules/@sentry/utils/esm/node.js:18:43
17 | /**
> 18 | * Requires a module which is protected against bundler minification.
> | ^^^^^^^^
19 | *
20 | * @param request The module path to resolve
💁 Possible Solution
idk.
🔦 Context
💻 Code Sample
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 2.3.1 |
Node | 16.11.1 |
npm/Yarn | yarn: 1.22.17 |
Operating System | mac osx |
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 19
- Comments: 57 (7 by maintainers)
Commits related to this issue
- Fix autoinstalling node builtins Fixes #7697 — committed to parcel-bundler/parcel by devongovett 2 years ago
- Fix autoinstalling node builtins (#7735) Fixes #7697 — committed to parcel-bundler/parcel by devongovett 2 years ago
- try workaround for `Build failed. 10:35:32 PM: @parcel/core: Failed to resolve 'process' from 10:35:32 PM: './node_modules/@sentry/utils/esm/node.js'` issue from https://github.com/parcel-bundler/parc... — committed to mikemoraned/quarterly-clock by mikemoraned 2 years ago
- Various package additions as workaround for pnpm autoinstall issue See https://github.com/parcel-bundler/parcel/issues/7697 — committed to jHwls/workshop-semantics-html-aria by jHwls a year ago
- add alias.process as false see https://github.com/parcel-bundler/parcel/issues/7697 — committed to conao3-playground/node-react-spectrum by conao3 a year ago
- fix: parcel failed to resolve 'process' due to parcel-bundler/parcel#7697 — committed to kleros/kleros-v2 by jaybuidl a year ago
- Workaround? https://github.com/parcel-bundler/parcel/issues/7697 — committed to RisingEmpires/aoe-4-countdown-timer by Coow 9 months ago
Have the same problem with
axios
.Temporary workaround is to add alias to
package.json
:@koskokos2 :
For me, I’ve added the following to my package.json :
"alias": { "process": false }
Now I can build on docker and it’s working fine on nginx (ya!) but on local it does not work anymore… (Process is undefined)
I think I’m gonna downgrade to parcel 2.2 for now until it’s resolved…
I was having this issue related to
js-sha256
https://github.com/parcel-bundler/parcel/issues/7060#issuecomment-1035880313
This solved it, in builds and dev. Basically, define process for the browser as an empty object:
Thanks to @mischnic - found the issue. Apparently pnpm autoinstall is broken.
Add these dev deps to your package.json. Note I was using parcel in a workspace, but these need to be installed in the project root.
Then add these alias to package.json:
Then install and run parcel, and you are back working!
also see node emulation
Any updates on this? Having the same issue.
I’m upgrading from 2.2.1 to 2.3.1, this time I’m getting same issue with NodeJS built-ins, for me it is Buffer.
@parcel/core: Failed to resolve 'buffer'
Still have this error in parcel 2.7.0, with pnpm. Can you fix it?
Having this error as well from migration from v1 to v2, even downgrading to 2.2 did not work, polyfill does not seem to be installing like the logs say.
"alias": { "process": "process/browser.js", "assert": "assert" }
worked for me to get around this, but had to manually install bothprocess
andassert
before the aliases were utilized.Alias Reference: https://parceljs.org/features/node-emulation/
another weird thing i noticed using the
alias
workaroundbuild works when explicitly providing a source
but it doesn’t work when you state a
source
as a field in thepackage.json
Having the same issue. For me it is with the contentful npm module.
It started with 2.3.0.
.parcelrc
(Same behaviour with empty .parcelrc)
Bump, this is still an issue on 2.8.0 My issue specifically came about when trying to use bcrypt. Parcel seems to try to polyfill a ton of dev dependencies including AWS SDK and process.
Using 2.7.0 I still had to apply the alias workaround.
v2.3.2 has a fix. Please let me know if it works for you.
@devongovett #7735 amazing, thank you for fixing!
I tried the following code:
and the console output was:
So, it auto installed
process
successfully and built. Is there another way to reproduce this?Ok, just for following up:
<project_root>/src/.env
<project_root>/.env
.parcel-cache
directory, ranparcel build
, then re-ranparcel serve
(somehow needed to runbuild
before…)@wesbos Can you share an example with the sentry and axios versions you’re using? And what exactly are you importing from them?
Using alias false doesn’t work:
Then it must come from my setup. Thanks for letting me know.
@eightyfive hey there - I’m running v14 node, just installed 2.3.2 parcel and I am loading a .env which appear to be loaded correctly. But I’m not sure if there’s something with my app/env that’s wildly different from yours - I’m sure there is just not sure what info you would need to help with that.
Did you try
?
Just changing process to the above as @MuhammadM1998 has without installing
process
as a dependancy worksRan into a similar sounding error using 2.3.1:
I had to go to the Node Emulation: Polyfilling & Excluding Builtin Node Modules table, find the package used for buffer, ie buffer, and manually install it. After that parcel was able to build successfully.
Similar to what tpudel described: https://github.com/parcel-bundler/parcel/issues/7697#issuecomment-1040867550 but I did not need to create the alias for buffer, just install the npm package.
node v14.17.1 npm 7.24.2 parcel 2.3.1
@koskokos2 if you run Parcel and pipe the output to cat you can see the full output.
parcel index.html | cat