webpack: Module parse failed. Unexpected character '#'.

What is the current behavior?

I am using electron-vue. I would like to write some unit test. But encountered the following error.

$npm run unit

> dockeron@0.0.1 unit /Users/fluency03/Workplace/github/dockeron
> cross-env BABEL_ENV=testing-unit karma start test/unit/karma.conf.js

(node:19628) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: bd5b9b00eb149df15584
Version: webpack 2.3.2
Time: 3925ms
   Asset     Size  Chunks  Chunk Names
index.js  1.41 MB       0  index.js
chunk    {0} index.js (index.js) 510 kB [entry] [rendered]
    [9] ./app/src/renderer/js/docker.js 389 bytes {0} [built]
   [10] ./app/src/renderer/vuex/modules/index.js 236 bytes {0} [built]
   [11] ./app/src/renderer/vuex/mutation-types.js 123 bytes {0} [built]
   [13] ./app/src/renderer/components/HomePageView.vue 1.63 kB {0} [built]
   [20] ./app/src/renderer/vuex/actions.js 306 bytes {0} [built]
   [21] ./app/src/renderer/vuex/getters.js 87 bytes {0} [built]
   [22] ./app/src/renderer/vuex/modules/counters.js 459 bytes {0} [optional] [built]
   [23] ./app/src/renderer/vuex/store.js 318 bytes {0} [built]
   [25] ./app/src/renderer/components/HomePageView/SingleContainerView.vue 1.7 kB {0} [built]
   [41] ./app/src/renderer/routes.js 273 bytes {0} [optional] [built]
   [42] ./app/src/renderer/App.vue 1.53 kB {0} [optional] [built]
   [45] ./app/src/renderer ^\.\/(?!main(\.js)?$) 796 bytes {0} [built]
   [46] ./test/unit/specs \.spec$ 184 bytes {0} [built]
   [96] ./test/unit/index.js 238 bytes {0} [built]
   [97] ./test/unit/specs/HomePageView.spec.js 455 bytes {0} [optional] [built]
     + 110 hidden modules

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
Child html-webpack-plugin for "index.html":
         Asset    Size  Chunks  Chunk Names
    index.html  544 kB       0
    chunk    {0} index.html 541 kB [entry]
        [0] ./~/lodash/lodash.js 540 kB {0} [built]
        [1] ./~/html-webpack-plugin/lib/loader.js!./app/index.ejs 1.02 kB {0} [built]
        [2] (webpack)/buildin/module.js 517 bytes {0} [built]

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:

    new webpack.DefinePlugin({
      '#! /usr/bin/env node': ''
    })

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 23 (5 by maintainers)

Most upvoted comments

Add another rule which only matches the JSONStream file. You current rule excludes node_modules.

@fluency03 Have you tried shebang-loader ?

Hi @fluency03! Is the issue resolved? I am experiencing the same issue with create-react-app here https://github.com/perliedman/query-overpass/issues/23