dvdzkwsk / react-redux-starter-kit

Get started with React, Redux, and React-Router.
MIT License
10.29k stars 2.2k forks source link

npm test fails in Ubuntu or Ubuntu in docker container #1037

Closed kyen99 closed 7 years ago

kyen99 commented 8 years ago

With a new clone of react-redux-starter-kit (c3abb2), npm test fails when run in a docker container with the official node image (tried 4.6, 6.6 and 6.7). Running npm test on the same source, locally on my mac, works, though (with node 6.7). When run in the docker container it seems to do some bundling with webpack. When run locally on my mac it does not, even with the same NODE_ENV=test in the environment.

Besides the error in the docker container, I can't understand why the npm test runs differently in the container vs outside the container. The only obvious difference I can see is linux vs mac.

Also, running npm test:dev does work in the docker container. It doesn't do any of the webpack stuff, same as it behaves on my mac.

Here is the output when run in the docker container...

root@e5c8d3eef1d8:/usr/src/app# npm test
npm info it worked if it ends with ok
npm info using npm@2.15.9
npm info using node@v4.6.0
npm info pretest react-redux-starter-kit@3.0.0-alpha.2
npm info test react-redux-starter-kit@3.0.0-alpha.2

> react-redux-starter-kit@3.0.0-alpha.2 test /usr/src/app
> better-npm-run test

running better-npm-run in /usr/src/app
Executing script: test

to be executed: node ./node_modules/karma/bin/karma start build/karma.conf 
  app:config Creating default configuration. +0ms
  app:config Looking for environment overrides for NODE_ENV "test". +3ms
  app:config No environment overrides found, defaults will be used. +2ms
  app:webpack:config Creating configuration. +675ms
  app:webpack:config Apply ExtractTextPlugin to CSS loaders. +98ms
  app:karma Creating configuration. +2ms

START:
Hash: a912ce28afb7ffdd8ed7
Version: webpack 1.13.2
Time: 43291ms
                                                         Asset       Size  Chunks             Chunk Names
                                         tests/test-bundler.js    2.53 MB       0  [emitted]  tests/test-bundler.js
    tests/test-bundler.js.50313958a3b619afc3f24e733292a1ab.css    8.08 kB       0  [emitted]  tests/test-bundler.js
                                     tests/test-bundler.js.map    3.04 MB       0  [emitted]  tests/test-bundler.js
tests/test-bundler.js.50313958a3b619afc3f24e733292a1ab.css.map    19.7 kB       0  [emitted]  tests/test-bundler.js
                                                   favicon.ico    24.8 kB          [emitted]  
                                                    index.html  879 bytes          [emitted]  
chunk    {0} tests/test-bundler.js, tests/test-bundler.js.50313958a3b619afc3f24e733292a1ab.css, tests/test-bundler.js.map, tests/test-bundler.js.50313958a3b619afc3f24e733292a1ab.css.map (tests/test-bundler.js) 2.46 MB [rendered]
    [0] ./tests/test-bundler.js 4.19 kB {0} [built]
    [1] ./~/sinon/pkg/sinon.js 139 kB {0} [built]
    [2] ./~/chai/index.js 50 bytes {0} [built]
    [3] ./~/chai/lib/chai.js 1.2 kB {0} [built]
    [4] ./~/chai/~/assertion-error/index.js 2.43 kB {0} [built]
    [5] ./~/babel-runtime/core-js/object/create.js 100 bytes {0} [built]
    [6] ./~/babel-runtime/~/core-js/library/fn/object/create.js 171 bytes {0} [built]
    [7] ./~/babel-runtime/~/core-js/library/modules/es6.object.create.js 166 bytes {0} [built]
    [8] ./~/babel-runtime/~/core-js/library/modules/_export.js 1.84 kB {0} [built]
    [9] ./~/babel-runtime/~/core-js/library/modules/_global.js 303 bytes {0} [built]
   [10] ./~/babel-runtime/~/core-js/library/modules/_core.js 119 bytes {0} [built]

... [lots of lines with no errors] ...

  [811] ./src/store/createStore.js 4.57 kB {0} [built]
  [812] ./~/redux-thunk/lib/index.js 416 bytes {0} [built]
  [813] ./tests/store/location.spec.js 9.38 kB {0} [optional] [built]
  [814] ./src ^((?!main|reducers).)*\.js$ 639 bytes {0} [built]
  [815] ./src/containers/AppContainer.js 2.98 kB {0} [optional] [built]
  [816] ./~/babel-runtime/helpers/classCallCheck.js 183 bytes {0} [built]
  [817] ./~/babel-runtime/helpers/createClass.js 762 bytes {0} [built]
  [818] ./~/babel-runtime/helpers/possibleConstructorReturn.js 472 bytes {0} [built]
  [819] ./~/babel-runtime/helpers/inherits.js 963 bytes {0} [built]
  [820] ./src/layouts/CoreLayout/index.js 764 bytes {0} [optional] [built]
  [821] ./src/routes/index.js 2.2 kB {0} [optional] [built]

ERROR in ./~/chai-enzyme/~/react-element-to-jsx-string/index-dist.js
Module build failed: Error: Couldn't find preset "stage-2" relative to directory "/usr/src/app/node_modules/chai-enzyme/node_modules/react-element-to-jsx-string"
    at /usr/src/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:298:19
    at Array.map (native)
    at OptionManager.resolvePresets (/usr/src/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:269:20)
    at OptionManager.mergePresets (/usr/src/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:258:10)
    at OptionManager.mergeOptions (/usr/src/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:243:14)
    at OptionManager.init (/usr/src/app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:373:12)
    at File.initOptions (/usr/src/app/node_modules/babel-core/lib/transformation/file/index.js:221:65)
    at new File (/usr/src/app/node_modules/babel-core/lib/transformation/file/index.js:141:24)
    at Pipeline.transform (/usr/src/app/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/usr/src/app/node_modules/babel-loader/index.js:38:20)
    at /usr/src/app/node_modules/babel-loader/lib/fs-cache.js:145:18
    at ReadFileContext.callback (/usr/src/app/node_modules/babel-loader/lib/fs-cache.js:28:23)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:303:13)
 @ ./~/chai-enzyme/build/assertions/contain.js 8:31-69

ERROR in   TypeError: $export is not a function

  - index.html:9637 Object.<anonymous>
    /usr/src/app/src/index.html:9637:2

  - index.html:21 __webpack_require__
    /usr/src/app/src/index.html:21:30

  - index.html:9630 Object.<anonymous>
    /usr/src/app/src/index.html:9630:15

  - index.html:21 __webpack_require__
    /usr/src/app/src/index.html:21:30

  - index.html:9624 Object.<anonymous>
    /usr/src/app/src/index.html:9624:41

  - index.html:21 __webpack_require__
    /usr/src/app/src/index.html:21:30

  - index.html:9618 Object.<anonymous>
    /usr/src/app/src/index.html:9618:35

  - index.html:21 __webpack_require__
    /usr/src/app/src/index.html:21:30

  - index.html:9612 Object.<anonymous>
    /usr/src/app/src/index.html:9612:22

  - index.html:21 __webpack_require__
    /usr/src/app/src/index.html:21:30

Child extract-text-webpack-plugin:
    chunk    {0} extract-text-webpack-plugin-output-filename 1.77 kB [rendered]
        [0] ./~/css-loader?sourceMap&-minimize!./~/postcss-loader!./~/sass-loader?sourceMap!./src/components/Header/Header.scss 534 bytes {0} [built]
        [1] ./~/css-loader/lib/css-base.js 1.24 kB {0} [built]
Child extract-text-webpack-plugin:
    chunk    {0} extract-text-webpack-plugin-output-filename 1.78 kB [rendered]
        [0] ./~/css-loader?sourceMap&-minimize!./~/postcss-loader!./~/sass-loader?sourceMap!./src/routes/Home/components/HomeView.scss 546 bytes {0} [built]
        [1] ./~/css-loader/lib/css-base.js 1.24 kB {0} [built]
Child extract-text-webpack-plugin:
    chunk    {0} extract-text-webpack-plugin-output-filename 1.72 kB [rendered]
        [0] ./~/css-loader?sourceMap&-minimize!./~/postcss-loader!./~/sass-loader?sourceMap!./src/layouts/CoreLayout/CoreLayout.scss 477 bytes {0} [built]
        [1] ./~/css-loader/lib/css-base.js 1.24 kB {0} [built]
Child extract-text-webpack-plugin:
    chunk    {0} extract-text-webpack-plugin-output-filename 28.9 kB [rendered]
        [0] ./~/css-loader?sourceMap&-minimize!./~/postcss-loader!./~/sass-loader?sourceMap!./src/styles/core.scss 27.7 kB {0} [built]
        [1] ./~/css-loader/lib/css-base.js 1.24 kB {0} [built]
Child html-webpack-plugin for "index.html":
         Asset    Size  Chunks       Chunk Names
    index.html  530 kB       0       
    chunk    {0} index.html 513 kB
        [0] ./~/html-webpack-plugin/lib/loader.js!./src/index.html 759 bytes {0} [built]
        [1] ./~/html-webpack-plugin/~/lodash/lodash.js 473 kB {0} [built]
        [2] (webpack)/buildin/module.js 220 bytes {0} [built]
        [3] ./~/babel-runtime/helpers/typeof.js 1.18 kB {0} [built]
        [4] ./~/babel-runtime/core-js/symbol/iterator.js 102 bytes {0} [built]
        [5] ./~/babel-runtime/~/core-js/library/fn/symbol/iterator.js 163 bytes {0} [built]
        [6] ./~/babel-runtime/~/core-js/library/modules/es6.string.iterator.js 437 bytes {0} [built]
        [7] ./~/babel-runtime/~/core-js/library/modules/_string-at.js 479 bytes {0} [built]
        [8] ./~/babel-runtime/~/core-js/library/modules/_to-integer.js 143 bytes {0} [built]
        [9] ./~/babel-runtime/~/core-js/library/modules/_defined.js 157 bytes {0} [built]
       [10] ./~/babel-runtime/~/core-js/library/modules/_iter-define.js 2.27 kB {0} [built]
       [11] ./~/babel-runtime/~/core-js/library/modules/_library.js 33 bytes {0} [built]
       [12] ./~/babel-runtime/~/core-js/library/modules/_export.js 1.84 kB {0} [built]
       [13] ./~/babel-runtime/~/core-js/library/modules/_global.js 303 bytes {0} [built]
       [14] ./~/babel-runtime/~/core-js/library/modules/_core.js 119 bytes {0} [built]
       [15] ./~/babel-runtime/~/core-js/library/modules/_ctx.js 421 bytes {0} [built]
       [16] ./~/babel-runtime/~/core-js/library/modules/_a-function.js 120 bytes {0} [built]
       [17] ./~/babel-runtime/~/core-js/library/modules/_hide.js 258 bytes {0} [built]
       [18] ./~/babel-runtime/~/core-js/library/modules/_object-dp.js 750 bytes {0} [built]
       [19] ./~/babel-runtime/core-js/object/define-property.js 109 bytes {0} [built]
       [20] ./~/babel-runtime/~/core-js/library/fn/object/define-property.js 212 bytes {0} [built]
       [21] ./~/babel-runtime/~/core-js/library/modules/es6.object.define-property.js 217 bytes {0} [built]
       [22] ./~/babel-runtime/~/core-js/library/modules/_descriptors.js 181 bytes {0} [built]
       [23] ./~/babel-runtime/~/core-js/library/modules/_fails.js 87 bytes {0} [built]
       [24] ./~/babel-runtime/~/core-js/library/modules/_an-object.js 148 bytes {0} [built]
       [25] ./~/babel-runtime/~/core-js/library/modules/_is-object.js 338 bytes {0} [built]
       [26] ./~/babel-runtime/~/core-js/library/modules/_ie8-dom-define.js 194 bytes {0} [built]
       [27] ./~/babel-runtime/~/core-js/library/modules/_dom-create.js 270 bytes {0} [built]
       [28] ./~/babel-runtime/~/core-js/library/modules/_to-primitive.js 600 bytes {0} [built]
       [29] ./~/babel-runtime/~/core-js/library/modules/_property-desc.js 142 bytes {0} [built]
       [30] ./~/babel-runtime/~/core-js/library/modules/_redefine.js 47 bytes {0} [built]
       [31] ./~/babel-runtime/~/core-js/library/modules/_has.js 119 bytes {0} [built]
       [32] ./~/babel-runtime/~/core-js/library/modules/_iterators.js 31 bytes {0} [built]
       [33] ./~/babel-runtime/~/core-js/library/modules/_iter-create.js 468 bytes {0} [built]
       [34] ./~/babel-runtime/~/core-js/library/modules/_object-create.js 1.52 kB {0} [built]
       [35] ./~/babel-runtime/core-js/object/create.js 100 bytes {0} [built]
       [36] ./~/babel-runtime/~/core-js/library/fn/object/create.js 171 bytes {0} [built]
       [37] ./~/babel-runtime/~/core-js/library/modules/es6.object.create.js 166 bytes {0} [built]
       [38] ./~/babel-runtime/~/core-js/library/modules/_object-dps.js 575 bytes {0} [built]
       [39] ./~/babel-runtime/core-js/object/define-properties.js 111 bytes {0} [built]
       [40] ./~/babel-runtime/~/core-js/library/fn/object/define-properties.js 202 bytes {0} [built]
       [41] ./~/babel-runtime/~/core-js/library/modules/es6.object.define-properties.js 217 bytes {0} [built]
       [42] ./~/babel-runtime/~/core-js/library/modules/_object-keys.js 395 bytes {0} [built]
       [43] ./~/babel-runtime/core-js/object/keys.js 98 bytes {0} [built]
       [44] ./~/babel-runtime/~/core-js/library/fn/object/keys.js 112 bytes {0} [built]
       [45] ./~/babel-runtime/~/core-js/library/modules/es6.object.keys.js 210 bytes {0} [built]
       [46] ./~/babel-runtime/~/core-js/library/modules/_to-object.js 133 bytes {0} [built]
       [47] ./~/babel-runtime/~/core-js/library/modules/_object-sap.js 323 bytes {0} [built]
       [48] ./~/babel-runtime/~/core-js/library/modules/_object-keys-internal.js 452 bytes {0} [built]
       [49] ./~/babel-runtime/~/core-js/library/modules/_to-iobject.js 211 bytes {0} [built]
       [50] ./~/babel-runtime/~/core-js/library/modules/_iobject.js 230 bytes {0} [built]
       [51] ./~/babel-runtime/~/core-js/library/modules/_cof.js 105 bytes {0} [built]
       [52] ./~/babel-runtime/~/core-js/library/modules/_array-includes.js 662 bytes {0} [built]
       [53] ./~/babel-runtime/~/core-js/library/modules/_to-length.js 202 bytes {0} [built]
       [54] ./~/babel-runtime/~/core-js/library/modules/_to-index.js 194 bytes {0} [built]
       [55] ./~/babel-runtime/~/core-js/library/modules/_shared-key.js 149 bytes {0} [built]
       [56] ./~/babel-runtime/~/core-js/library/modules/_shared.js 181 bytes {0} [built]
       [57] ./~/babel-runtime/~/core-js/library/modules/_uid.js 145 bytes {0} [built]
       [58] ./~/babel-runtime/~/core-js/library/modules/_enum-bug-keys.js 164 bytes {0} [built]
       [59] ./~/babel-runtime/~/core-js/library/modules/_html.js 84 bytes {0} [built]
       [60] ./~/babel-runtime/~/core-js/library/modules/_set-to-string-tag.js 228 bytes {0} [built]
       [61] ./~/babel-runtime/~/core-js/library/modules/_wks.js 315 bytes {0} [built]
       [62] ./~/babel-runtime/~/core-js/library/modules/_object-gpo.js 664 bytes {0} [built]
       [63] ./~/babel-runtime/core-js/object/get-prototype-of.js 110 bytes {0} [built]
       [64] ./~/babel-runtime/~/core-js/library/fn/object/get-prototype-of.js 134 bytes {0} [built]
       [65] ./~/babel-runtime/~/core-js/library/modules/es6.object.get-prototype-of.js 258 bytes {0} [built]
       [66] ./~/babel-runtime/~/core-js/library/modules/web.dom.iterable.js 469 bytes {0} [built]
       [67] ./~/babel-runtime/~/core-js/library/modules/es6.array.iterator.js 952 bytes {0} [built]
       [68] ./~/babel-runtime/~/core-js/library/modules/_add-to-unscopables.js 52 bytes {0} [built]
       [69] ./~/babel-runtime/~/core-js/library/modules/_iter-step.js 83 bytes {0} [built]
       [70] ./~/babel-runtime/~/core-js/library/modules/_wks-ext.js 41 bytes {0} [built]
       [71] ./~/babel-runtime/core-js/symbol.js 93 bytes {0} [built]
       [72] ./~/babel-runtime/~/core-js/library/fn/symbol/index.js 246 bytes {0} [built]
       [73] ./~/babel-runtime/~/core-js/library/modules/es6.symbol.js 7.7 kB {0} [built]
       [74] ./~/babel-runtime/~/core-js/library/modules/_meta.js 1.87 kB {0} [built]
       [75] ./~/babel-runtime/core-js/object/prevent-extensions.js 112 bytes {0} [built]
       [76] ./~/babel-runtime/~/core-js/library/fn/object/prevent-extensions.js 139 bytes {0} [built]
       [77] ./~/babel-runtime/~/core-js/library/modules/es6.object.prevent-extensions.js 313 bytes {0} [built]
       [78] ./~/babel-runtime/core-js/object/is-extensible.js 107 bytes {0} [built]
       [79] ./~/babel-runtime/~/core-js/library/fn/object/is-extensible.js 129 bytes {0} [built]
       [80] ./~/babel-runtime/~/core-js/library/modules/es6.object.is-extensible.js 251 bytes {0} [built]
       [81] ./~/babel-runtime/~/core-js/library/modules/_wks-define.js 364 bytes {0} [built]
       [82] ./~/babel-runtime/~/core-js/library/modules/_keyof.js 255 bytes {0} [built]
       [83] ./~/babel-runtime/~/core-js/library/modules/_enum-keys.js 386 bytes {0} [built]
       [84] ./~/babel-runtime/~/core-js/library/modules/_object-gops.js 305 bytes {0} [built]
       [85] ./~/babel-runtime/core-js/object/get-own-property-symbols.js 118 bytes {0} [built]
       [86] ./~/babel-runtime/~/core-js/library/fn/object/get-own-property-symbols.js 124 bytes {0} [built]
       [87] ./~/babel-runtime/~/core-js/library/modules/_object-pie.js 47 bytes {0} [built]
       [88] ./~/babel-runtime/~/core-js/library/modules/_is-array.js 145 bytes {0} [built]
       [89] ./~/babel-runtime/~/core-js/library/modules/_object-gopn-ext.js 960 bytes {0} [built]
       [90] ./~/babel-runtime/core-js/object/get-own-property-names.js 116 bytes {0} [built]
       [91] ./~/babel-runtime/~/core-js/library/fn/object/get-own-property-names.js 211 bytes {0} [built]
       [92] ./~/babel-runtime/~/core-js/library/modules/es6.object.get-own-property-names.js 155 bytes {0} [built]
       [93] ./~/babel-runtime/~/core-js/library/modules/_object-gopn.js 523 bytes {0} [built]
       [94] ./~/babel-runtime/~/core-js/library/modules/_object-gopd.js 760 bytes {0} [built]
       [95] ./~/babel-runtime/core-js/object/get-own-property-descriptor.js 121 bytes {0} [built]
       [96] ./~/babel-runtime/~/core-js/library/fn/object/get-own-property-descriptor.js 234 bytes {0} [built]
       [97] ./~/babel-runtime/~/core-js/library/modules/es6.object.get-own-property-descriptor.js 325 bytes {0} [built]
       [98] ./~/babel-runtime/~/core-js/library/modules/es6.object.to-string.js 13 bytes {0} [built]
       [99] ./~/babel-runtime/~/core-js/library/modules/es7.symbol.async-iterator.js 55 bytes {0} [built]
      [100] ./~/babel-runtime/~/core-js/library/modules/es7.symbol.observable.js 52 bytes {0} [built]
      [101] (webpack)/buildin/amd-options.js 43 bytes {0} [built]
05 10 2016 04:11:58.990:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
05 10 2016 04:11:58.993:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
05 10 2016 04:11:59.097:INFO [launcher]: Starting browser PhantomJS
05 10 2016 04:12:01.076:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#T9baVa3CL-6c6Vi1AAAA with id 28152969
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  TypeError: false is not a function (evaluating 'require('babel-runtime/core-js/clear-immediate')')
  at webpack:///~/sinon/pkg/sinon.js:1:0 <- tests/test-bundler.js:69

Finished in 0.57 secs / 0 secs

SUMMARY:
✔ 0 tests completed
npm info react-redux-starter-kit@3.0.0-alpha.2 Failed to exec test script
npm ERR! Test failed.  See above for more details.
ghost commented 8 years ago

@kyen99 I don't see a Dockerfile or stated support for Docker in this repo. I'm sure David would appreciate less issues and more PRs.

kyen99 commented 8 years ago

@jhabdas, agreed I should have included a link to a fork that contains the Dockerfile (also included below). Regarding David appreciating more PRs than issues, I don't see how I can submit a PR until I can resolve the issue. Are you suggesting that I should have submitted a PR with the Dockerfile and put my issue into the PR notes? I will absolutely submit a proper PR when I can resolve this.

Here is a fork that contains the Dockerfile: https://github.com/purple-squirrel-io/react-redux-starter-kit

I build a container using: docker build . -t rsk

then run the test using: docker run -it rsk npm test

The Dockerfile is also here (which is all that is needed):

FROM node:4
EXPOSE 3000
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
CMD [ "npm", "run", "start:prod" ]
kyen99 commented 8 years ago

After more debugging on this issue, I realize that it's not that something different is done in the docker container vs my mac, but that webpack doesn't show any output unless there is an error. I also don't think Docker has anything to do with this. I think there is just an issue running npm test on Debian 8 (jessie). Maybe it has something to do with an npm package. I'll keep trying to track down the issue.

sh-rp commented 8 years ago

I see the exact same error happening on Ubuntu with a vanilla checkout of the 3.0.0 alpha 2. It looks like a problem with PhantomJS?

kyen99 commented 8 years ago

The more I look at the errors, the more I think it's an issue with babel-runtime or a babel plugin. Even if I resolve the stage-2 preset error I still can't resolve...

ERROR in TypeError: $export is not a function

kowalski commented 8 years ago

I run into the same problem. What helped was:

diff --git a/src/frontend/build/karma.conf.js b/src/frontend/build/karma.conf.js
index 4602dc7..c692b5c 100644
--- a/src/frontend/build/karma.conf.js
+++ b/src/frontend/build/karma.conf.js
@@ -62,6 +62,7 @@ if (config.globals.__COVERAGE__) {
   karmaConfig.webpack.module.preLoaders = [{
     test    : /\.(js|jsx)$/,
     include : new RegExp(config.dir_client),
+    exclude : /node_modules/,
     loader  : 'babel',
     query   : Object.assign({}, config.compiler_babel, {
       plugins : (config.compiler_babel.plugins || []).concat('istanbul')
kyen99 commented 8 years ago

Yep, that fixed the issue. Thanks for taking the time to post the solution. I'm going to submit this as a PR.

dvdzkwsk commented 7 years ago

Looks like this has been merged; thanks again!