Skip to content
This repository has been archived by the owner. It is now read-only.

Can't be loaded by webpack #126

Closed
zhaoyi0113 opened this issue Apr 14, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@zhaoyi0113
Copy link

commented Apr 14, 2017

I am trying to load JSONStream through webpack but failed with below error:

ERROR in ./~/JSONStream/index.js
Module parse failed: /Project/node_modules/JSONStream/index.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
| #! /usr/bin/env node

I found that the first line of index.js is #! /usr/bin/env node which gives such problem. Is there a way for me to load this module through webpack?

@dominictarr

This comment has been minimized.

Copy link
Owner

commented Apr 18, 2017

you should file this as a bug in webpack. I am sure there are loads of other modules that have this, and this is a very popular module that has been this way for a long time, it would be much easier to fix this in webpack than to fix every module which uses this. Browserify can handle this, btw.

@corysimmons

This comment has been minimized.

Copy link

commented May 10, 2017

Here's the issue if anyone's interested.

@imerkle

This comment has been minimized.

Copy link

commented Oct 14, 2017

I't doesn't solves it.

@mrchief

This comment has been minimized.

Copy link

commented Oct 25, 2017

hash bang is not valid JavaScript. Its interpreted by node js but that doesn't make it valid JS.

I am sure there are loads of other modules that have this

There are few but not many. At least not libs that aim to work in both node as well as browser. And it doesn't work on Windows as well.

There is no value in the hash bang. Node JS will interpret it correctly either way. I doubt webpack will ever address it, since its not a webpack issue technically. Its one of those issues which can be argued to death either which way.

In the end, it boils down to this - Do you envision the greater use case of this lib as a shell script or as a node package? Do you want this lib to be restricted to "linux+node" only environment (for having that 1 line) or do you want to open it up to much larger audience (and get rid of the line).

For folks looking for work-around:

  • Use a fork like jsonstream2
  • Use something like shebang-loader which will ignore that line (this grows tiresome quickly with more such libs).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.