Repository navigation
Module parse failed. Unexpected character '#'. #4603
Description
Activity
This is a flag about this module being a node.js cli tool.
In general it doesn't make sense to bundle a CLI "tool".
In this case it seem to be a combined CLI + LIB module. (not best practice?)
As workaround you can write a loader removing the hashbag or send a PR splitting the CLI part in to a separate file in JSONStream.
@sokra THanks. I am new to webpack. Could you give me more idea about how to write a loader?
And btw, what is PR?
module.exports = function(source) { return source.replace(/^#! .*\n/, ""); };
@sokra Thanks. I will try this out and keep it updated.
@sokra I have add the
remove-hashbag-loader:module.exports = function (source) { return source.replace(/^#! .*\n/, '') }
and in webpack config:
{ test: /\.js$/, use: ['babel-loader', 'remove-hashbag-loader'] include: [ path.resolve(__dirname, 'app/src/renderer') ], exclude: /node_modules/ },
and:
resolveLoader: { alias: { 'remove-hashbag-loader': path.join(__dirname, './loaders/remove-hashbag-loader') } },
But still got the save error:
ERROR in ./app/~/JSONStream/index.js Module parse failed: /Users/fluency03/Workplace/github/dockeron/app/node_modules/JSONStream/index.js Unexpected character '#' (1:0) You may need an appropriate loader to handle this file type. | #! /usr/bin/env node | | var Parser = require('jsonparse') @ ./app/~/docker-modem/lib/modem.js 11:15-36 @ ./app/~/dockerode/lib/docker.js @ ./app/src/renderer/js/docker.js @ ./app/src/renderer ^\.\/(?!main(\.js)?$) @ ./test/unit/index.js@sokra I have also tried directly use:
{ test: /\.js$/, use: [ 'babel-loader', require.resolve('./loaders/remove-hashbag-loader') ], include: [ path.resolve(__dirname, 'app/src/renderer') ], exclude: /node_modules/ },
no luck as well.
Add another rule which only matches the JSONStream file. You current rule excludes node_modules.
Reacted by Chang Liu and Shimrit SnapirReacted by dengyongqing and Shimrit SnapirReacted by dengyongqing and Shimrit SnapirReacted by dengyongqingHi @fluency03! Is the issue resolved? I am experiencing the same issue with
create-react-apphere perliedman/query-overpass#23Reacted by Kiptoo MaguttThis should work fine.
module.exports = function(source) { return source.replace(/^.*#!.*$/mg, ""); };
For the next person who runs into the issue, here's how I fixed it thanks to the helpful hints from @fluency03 and @sokra:
Web pack config (in my case
webpack.renderer.config.js):... module: { rules: [ { test: /\.js$/, use: ["remove-hashbag-loader"] } ... ] }, resolveLoader: { alias: { "remove-hashbag-loader": path.join(__dirname, "./loaders/remove-hashbag-loader") } }
In
loaders/remove-hashbag-loader.js:module.exports = function(source) { return source.replace(/^#! .*\n/, ""); };
@fluency03 Have you tried shebang-loader ?
Reacted by Amer Lotfi Orimi, PinnacleOne and Mateja Petrovic- Reacted by Wouter Vanherck, PinnacleOne and Roman Hotsiy
This issue is now resolved as the JSONStream has been updated here: dominictarr/JSONStream@debb492
- addedhelp wantedMaintainers welcome a community PR for thisMaintainers welcome a community PR for this
on Feb 21, 2018 @fr-ser The accepted answer of that question didn't exactly resolve the
Unexpected character '#issue because it was depricated. However, the comments helped me out. After that, a new issue occured:TypeError: str.indexOf is not a function at wrapComment (...\node_modules\webpack\lib\BannerPlugin.js:9:9) at new BannerPlugin (...\node_modules\webpack\lib\BannerPlugin.js:15:44) at Object.<anonymous> (...\config\webpack.config.prod.js:261:5) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) at Module.require (module.js:587:17) at require (internal/module.js:11:18) at Object.<anonymous> (...\scripts\build.js:17:14) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3)Have you had the same problem? How did you resolve it?
Original issue was solved. Thanks everyone.
@WouterVanherck you useBannerPluginforshebang. Please recreate separate other issue. Thanks!please help for this problem...
C:\Users\Noargs\Documents\Angular>cd my-app
C:\Users\Noargs\Documents\Angular\my-app>ng serve --open
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **Date: 2018-08-24T06:23:17.081Z
Hash: 45253f019453bff022b4
Time: 7394ms
chunk {main} main.js, main.js.map (main) 11.1 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.26 MB [initial] [rendered]ERROR in ./ansi-html
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
| #!/bin/sh
| basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")
|
i 「wdm」: Failed to compile.
Terminate batch job (Y/N)? yC:\Users\Noargs\Documents\Angular\my-app>ng version
_ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|/ △ \ | '_ \ /
| | | | |/ _| '__| | | | | | |
/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/Angular CLI: 6.1.5
Node: 8.11.3
OS: win32 x64
Angular: 6.1.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, routerPackage Version
@angular-devkit/architect 0.7.5
@angular-devkit/build-angular 0.7.5
@angular-devkit/build-optimizer 0.7.5
@angular-devkit/build-webpack 0.7.5
@angular-devkit/core 0.7.5
@angular-devkit/schematics 0.7.5
@angular/cli 6.1.5
@ngtools/webpack 6.1.5
@schematics/angular 0.7.5
@schematics/update 0.7.5
rxjs 6.2.2
typescript 2.7.2
webpack 4.9.2Bump
Hi guys,
Can any one suggest me, how to resolved this,After
$ng servecomes this errors:
`
ERROR in ./ansi-html 1:0
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.#!/bin/sh
| basedir=$(dirname "$(echo "$0" | sed -e 's,\,/,g')")
|
i 「wdm」: Failed to compile.
`Same problem when I'm working on Vue, using Echarts-GL. This error happened when I try to require a .hdr file.
Same problem when I'm working on Vue, using Echarts-GL. This error happened when I try to require a .hdr file.
Did you solve it? I've got the same problem with hdr file.
@odd-one I didn't solve that problem... I used .png to replace that hdr texture.
@odd-one I didn't solve that problem... I used .png to replace that hdr texture.
I think I just did it though. Try this:
.load(require ('file-loader!path/to/image.hdr')
you need to install file-loader with
npm install file-loaderThis works with vue.js + webpack + threejs
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
What is the current behavior?
I am using electron-vue. I would like to write some unit test. But encountered the following error.
If the current behavior is a bug, please provide the steps to reproduce.
You can find the code here.
The most relevant parts are:
I have tried add:
but no luck.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Node.js: 7.7.4
Webpack: 2.3.2
Operating System: OSX