forge icon indicating copy to clipboard operation
forge copied to clipboard

ERROR in ./src/app.jsx 10:9

Open sdeass opened this issue 2 years ago • 2 comments

Pre-flight checklist

  • [X] I have read the contribution documentation for this project.
  • [X] I agree to follow the code of conduct that this project uses.
  • [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.3.0

Electron version

29.0.1

Operating system

macOS sonoma 14.3

Last known working Electron Forge version

none

Expected behavior

build succeed while run script npm run make

Actual behavior

const { resolve } = require("./pathUtils");

module.exports = [ // Add support for native node modules { // We're specifying native_modules in the test because the asset relocator loader generates a // "fake" .node file which is really a cjs file. test: /native_modules[/\].+.node$/, use: 'node-loader', }, { test: /[/\]node_modules[/\].+.(m?js|node)$/, parser: { amd: false }, use: { loader: '@vercel/webpack-asset-relocator-loader', options: { outputAssetBase: 'native_modules', }, }, }, { test: /.jsx?$/, include: resolve("src"), use: [ { loader: "babel-loader", options: { exclude: /node_modules/, presets: ["@babel/preset-react","@babel/preset-env"], plugins: ["@babel/plugin-transform-react-jsx"] } }, ], }, { test: /.html$/, use: [ { loader: "html-loader", }, ], } ];

[email protected] make electron-forge make

✔ Checking your system ✔ Loading configuration ✔ Resolving make targets › Making for the following targets: ❯ Running package command ✔ Preparing to package application ❯ Running packaging hooks ✔ Running generateAssets hook ❯ Running prePackage hook ❯ [plugin-webpack] Preparing webpack bundles ✔ Preparing native dependencies [0.4s] ✖ Building webpack bundles › Compilation errors in the renderer: asset main_w… runtime modules 0 bytes 1 module ./src/preload.js 158 bytes [built] [code generat… webpack 5.90.3 compiled successfully in 290 ms assets by status 5.53 KiB [cached] 2 assets runtime modules 796 bytes 5 modules orphan modules 1.11 KiB [orphan] 1 module cacheable modules 11 KiB modules by path ./node_modules/ 8.58 KiB modules by path ./node_modules/style-loader/dist… ./node_modules/style-loader/dist/runtime/injectS… ./node_modules/style-loader/dist/runtime/styleDo… + 4 modules modules by path ./node_modules/css-loader/dist/r… ./node_modules/css-loader/dist/runtime/sourceMap… ./node_modules/css-loader/dist/runtime/api.js 2.… modules by path ./src/ 2.38 KiB ./src/renderer.js + 1 modules 1.15 KiB [built] [… ./src/app.jsx 323 bytes [built] [code generated]… ./node_modules/css-loader/dist/cjs.js!./src/inde… ERROR in ./src/app.jsx 10:9 Module parse failed: Unexpected token (10:9) You may need an appropriate loader to handle thi… | }); | > return

hello world
| } | @ ./src/renderer.js 1:0-18 webpack 5.90.3 compiled with 1 error in 621 ms ◼ Packaging application ◼ Running postPackage hook ◼ Running preMake hook ◼ Making distributables ◼ Running postMake hook

Steps to reproduce

const { resolve } = require("./pathUtils");

module.exports = [ // Add support for native node modules { // We're specifying native_modules in the test because the asset relocator loader generates a // "fake" .node file which is really a cjs file. test: /native_modules[/\].+.node$/, use: 'node-loader', }, { test: /[/\]node_modules[/\].+.(m?js|node)$/, parser: { amd: false }, use: { loader: '@vercel/webpack-asset-relocator-loader', options: { outputAssetBase: 'native_modules', }, }, }, { test: /.jsx?$/, include: resolve("src"), use: [ { loader: "babel-loader", options: { exclude: /node_modules/, presets: ["@babel/preset-react","@babel/preset-env"], plugins: ["@babel/plugin-transform-react-jsx"] } }, ], }, { test: /.html$/, use: [ { loader: "html-loader", }, ], } ];

[email protected] make electron-forge make

✔ Checking your system ✔ Loading configuration ✔ Resolving make targets › Making for the following targets: ❯ Running package command ✔ Preparing to package application ❯ Running packaging hooks ✔ Running generateAssets hook ❯ Running prePackage hook ❯ [plugin-webpack] Preparing webpack bundles ✔ Preparing native dependencies [0.4s] ✖ Building webpack bundles › Compilation errors in the renderer: asset main_w… runtime modules 0 bytes 1 module ./src/preload.js 158 bytes [built] [code generat… webpack 5.90.3 compiled successfully in 290 ms assets by status 5.53 KiB [cached] 2 assets runtime modules 796 bytes 5 modules orphan modules 1.11 KiB [orphan] 1 module cacheable modules 11 KiB modules by path ./node_modules/ 8.58 KiB modules by path ./node_modules/style-loader/dist… ./node_modules/style-loader/dist/runtime/injectS… ./node_modules/style-loader/dist/runtime/styleDo… + 4 modules modules by path ./node_modules/css-loader/dist/r… ./node_modules/css-loader/dist/runtime/sourceMap… ./node_modules/css-loader/dist/runtime/api.js 2.… modules by path ./src/ 2.38 KiB ./src/renderer.js + 1 modules 1.15 KiB [built] [… ./src/app.jsx 323 bytes [built] [code generated]… ./node_modules/css-loader/dist/cjs.js!./src/inde… ERROR in ./src/app.jsx 10:9 Module parse failed: Unexpected token (10:9) You may need an appropriate loader to handle thi… | }); | > return

hello world
| } | @ ./src/renderer.js 1:0-18 webpack 5.90.3 compiled with 1 error in 621 ms ◼ Packaging application ◼ Running postPackage hook ◼ Running preMake hook ◼ Making distributables ◼ Running postMake hook

Additional information

图像2024-2-23 11 36 图像2024-2-23 11 33 (1) 图像2024-2-23 11 33

sdeass avatar Feb 23 '24 03:02 sdeass

Hi, I suggest you should follow this guide on "How to create an Electron app with React and Electron Forge".

Maybe this will help fix your errors.

DevanceJ avatar Mar 30 '24 23:03 DevanceJ