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

SyntaxError: Unexpected token ‘(’ when importing @sentry/webpack-plugin in custom-webpack #592

Open
liangzhengcongyfd opened this issue Aug 27, 2024 · 5 comments

Comments

@liangzhengcongyfd
Copy link

An error occurred while trying to import the @sentry/webpack-plugin in custom-webpack.config.js.

Environment

npm: v14.2.0
@angular/core: 10.2.5
webpack: 4.46.0
@angular-builders/custom-webpack: 10.0.1
@sentry/angular : 7.75.1
@sentry/tracing: 7.75.1
@sentry/webpack-plugin: 2.22.2

Steps to Reproduce

  1. "yarn add @sentry/webpack-plugin -dev"
  2. in custom-webpack.config.js: "import/require: const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');"
  3. "yarn start" or "yarn build" getting an error

Expected Result

no error

Actual Result

[error] /node_modules/@sentry/bundler-plugin-core/node_modules/minimatch/dist/cjs/ast.js:86
#fillNegs() {
^

SyntaxError: Unexpected token '('

@lforst
Copy link
Member

lforst commented Aug 27, 2024

Hi, I cannot reproduce this locally with the steps you provided. Would you mind sharing a small reproduction example in the form of a repo or stackblitz? Thanks!

@liangzhengcongyfd
Copy link
Author

liangzhengcongyfd commented Aug 28, 2024

Hi, I cannot reproduce this locally with the steps you provided. Would you mind sharing a small reproduction example in the form of a repo or stackblitz? Thanks!

Hi! Of course, here is the repo. You can reproduce the issue by running 'npm run build' or 'npm run start'. Thanks for your reply!

sentry-demo-repo
node: v14.2.0 / npm: 6.14.4

The issue is not accurately reproduced on StackBlitz, but it does occur when running the repository locally. Here is the StackBlitz link.
sentry-demo-stackblitz

@lforst
Copy link
Member

lforst commented Aug 28, 2024

Hi, can you try bumping your node version to version 14.6.0?

@liangzhengcongyfd
Copy link
Author

Hi, can you try bumping your node version to version 14.6.0?

Hi, Of course, I bumped my Node.js version to 14.6.0 and reinstalled @sentry/webpack-plugin. @sentry/webpack-plugin has been bumped to version 2.22.3. However, I encountered a new issue:

[error] Error: Cannot find module 'node:path'
Require stack:

Here is the repo:
sentry-demo-repo
node:14.6.0

BTW, is there an alternative way to solve this without bumping the Node.js version?

@lforst
Copy link
Member

lforst commented Aug 29, 2024

BTW, is there an alternative way to solve this without bumping the Node.js version?

Likely no. I have to admit we (I) kinda fucked up by specifying the node version range in the engines field to >= 14 which is not entirely correct. We likely won't bump it now without a major release because it runs risk of breaking CIs that check for the engines field. I think the actual minimum version required to run the plugin is node version 14.18.0, however I recommend running the latest v14 version which is 14.21.3 I believe. Node 14 is EOL for quite a while now.

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

No branches or pull requests

2 participants