Module parse failed importing autocannon on a electron app with webpack
See original GitHub issueI’m building an electron app, I’m trying to use this library but I got the following error when trying to import it.
ERROR in ./app/~/autocannon/autocannon.js
Module parse failed: /Users/ndelvalle/workspaces/muzen/app/node_modules/autocannon/autocannon.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '#' (1:0)
at Parser.pp$4.raise (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp$7.getTokenFromCode (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2756:10)
at Parser.pp$7.readToken (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2477:17)
at Parser.pp$7.nextToken (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2468:15)
at Parser.parse (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:515:10)
at Object.parse (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/ndelvalle/workspaces/muzen/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock.<anonymous> (/Users/ndelvalle/workspaces/muzen/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/Users/ndelvalle/workspaces/muzen/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /Users/ndelvalle/workspaces/muzen/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
@ ./~/babel-loader!./~/vue-loader/lib/selector.js?type=script&index=0!./app/src/components/main/harass/Harass.vue 8:17-38
Removing the shebang line didn’t solve it, It creates lots of warnings like:
WARNING in ./app/~/native-hdr-histogram/histogram.js
Critical dependencies:
6:16-37 the request of a dependency is an expression
@ ./app/~/native-hdr-histogram/histogram.js 6:16-37
WARNING in ./app/~/native-hdr-histogram/LICENSE
Module parse failed: /Users/ndelvalle/workspaces/muzen/app/node_modules/native-hdr-histogram/LICENSE Unexpected token (1:21)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:21)
at Parser.pp$4.raise (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseTopLevel (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/ndelvalle/workspaces/muzen/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock.<anonymous> (/Users/ndelvalle/workspaces/muzen/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/Users/ndelvalle/workspaces/muzen/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /Users/ndelvalle/workspaces/muzen/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
@ ./app/~/native-hdr-histogram ^\.\/.*$
WARNING in ./app/~/native-hdr-histogram/Makefile
Module parse failed: /Users/ndelvalle/workspaces/muzen/app/node_modules/native-hdr-histogram/Makefile Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '#' (1:0)
at Parser.pp$4.raise (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp$7.getTokenFromCode (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2756:10)
at Parser.pp$7.readToken (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2477:17)
at Parser.pp$7.nextToken (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:2468:15)
at Parser.parse (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:515:10)
at Object.parse (/Users/ndelvalle/workspaces/muzen/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/Users/ndelvalle/workspaces/muzen/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock.<anonymous> (/Users/ndelvalle/workspaces/muzen/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /Users/ndelvalle/workspaces/muzen/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/Users/ndelvalle/workspaces/muzen/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /Users/ndelvalle/workspaces/muzen/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
@ ./app/~/native-hdr-histogram ^\.\/.*$
Any ideas that could help me out using the lib in this environment?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
electron-webpack-react error "Module parse failed
I'm using Electron, Webpack and React on this project. When I try to build the project, I end up with this error: Module...
Read more >mcollina/autocannon - Gitter
Hi, Im trying to use this package on an electron app, when trying to import it I got the following error: ERROR in...
Read more >Webpack Module Parse Failed - React - jQWidgets
and I have used the es6 import statement to import the “react_jqxgrid.js” into one of my components. When I run “npm start” I...
Read more >electron-store - npm.io
Electron doesn't have a built-in way to persist user preferences and other data. This module handles that for you, so you can focus...
Read more >Module Parse Failed (webpack issue?) - Get Help - Vue Forum
The package you are trying to import is a Node package. You have to use require to add it to your project. e.g....
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 Free
Top 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
Hi @mcollina the problem was that I didn’t remove the dependency from the renderer (I ended up having the dependency in the main process and the renderer). I just rebuild the natives modules for the main process.
So following your approach of running the lib in the main process and rebuilding the native modules as shown in the link provided by @thekemkid is working fine 👍
Thanks for the help and the awesome library.
Could you also try follow these instructions when doing the dependency install? : http://electron.atom.io/docs/tutorial/using-native-node-modules/