Module build failed with Webpack / Typescript boilerplate & fs-extra
See original GitHub issueIssue Details
Electron Forge Version: 6.0.0-beta.47 OS: macOS 10.14.6
Expected Behavior
Ability to bundle app and use fs-extra module
Actual Behavior
Upon attempting to use any methods within fs-extra module hit a ‘module build failed’ error.
To Reproduce
yarn create electron-app my-new-app --template=typescript-webpack
yarn add fs-extra
Then update the typescript loader config in webpack.rules.js to the following [else webpack build fails, seems like template is currently broken]:
{
test: /\.tsx?$/,
exclude: /(node_modules|\.webpack)/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true
}
}
Then enable node-integration in browser window, update renderer.ts
to:
import "./index.css"
import fse from "fs-extra"
fse.access("./test")
console.log(
'👋 This message is being logged by "renderer.js", included via webpack'
)
and finally: yarn start
Additional Information
`index.js:14 Uncaught Error: Module build failed (from ./node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js):
SyntaxError: Unexpected token (86:14)
at Object.module.exports.pp$4.raise (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20834)
at Object.module.exports.pp.unexpected (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18680)
at Object.module.exports.pp$1.parseTryStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19069)
at Object.module.exports.pp$1.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18834)
at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4539)
at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:42314)
at Object.module.exports.pp$1.parseBlock (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19157)
at Object.module.exports.pp$1.parseTryStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19073)
at Object.module.exports.pp$1.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:18834)
at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4539)
at Object.parseStatement (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:42314)
at Object.module.exports.pp$1.parseBlock (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:19157)
at Object.module.exports.pp$3.parseFunctionBody (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20675)
at Object.module.exports.pp$3.parseArrowExpression (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20638)
at Object.module.exports.pp$3.parseExprAtom (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:20227)
at Object.parseExprAtom (Users/daniel.e.lewis/Documents/Learning/electron-webpack-typescript/node_modules/@marshallofsound/webpack-asset-relocator-loader/dist/index.js:4551)
at Object../node_modules/fs-extra/lib/mkdirs/make-dir.js (index.js:14)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Object../node_modules/fs-extra/lib/mkdirs/index.js (index.js:3)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Object../node_modules/fs-extra/lib/copy-sync/copy-sync.js (copy-sync.js:5)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Object../node_modules/fs-extra/lib/copy-sync/index.js (index.js:4)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Module build failed with Webpack / Typescript boilerplate & ...
Issue Details. Electron Forge Version: 6.0.0-beta.47. OS: macOS 10.14.6. Expected Behavior. Ability to bundle app and use fs-extra module ...
Read more >TypeScript
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >Module not found: Error: Can't resolve 'fs' in
For me the solution was to add this to the webpack config: config.node = { fs: 'empty', }. Another solution if you use...
Read more >webpack/webpack - Gitter
Hey folks, getting this error from webpack: ERROR in NormalModuleFactory.beforeResolve is no longer a waterfall hook, but a bailing hook instead.
Read more >Setting up a TypeScript Electron app in WebPack
A walkthrough of setting up a WebPack 2 based build process for creating an Electron application in TypeScript, including configuring a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Rolling back
fs-extra
to8.1.0
resolved the issue for me, I have not tracked down exactly what is causing the issue with9.x.x
. Though it may be a good plan to raise an issue on the fs-extra project.I’m also seeing some issues with this. I found that the following configuration helps but it actually doesn’t solve the problem completely: