问:
R subtracting 1 month from today's date gives NA
I have a script in which I subset my data according to some set time periods and wanted to subset all the records that had occurred in the last month.

However if I try to subtract one month from today's date it yields an NA:

```<code>> today <- Sys.Date()
> today
[1] "2017-03-29"
> today - months(1)
[1] NA
</code>```

I do have lubridate loaded but I think this calculation is being performed with base R.  If I subtract 2 or more months it works fine:

```<code>> today - months(2)
[1] "2017-01-29"
> today - months(3)
[1] "2016-12-29"
</code>```

Does anyone have any ideas about what might be going on?

UPDATE: I think this is something to do with simple date subtraction not handling leap year cases (2017 is not a leap year so "2017-02-29" does not exist).

Are there other packages / functions that take into account leap years?  For the above example I would expect the answer to revert to the last day of the previous month, i.e.:

```<code>today - months(1)
# Should yield:
"2017-02-28"
</code>```

Would it make sense for this calculation to give the same results for both today and yesterday (or what is the ISO convention for this)?

```<code>> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] xlsx_0.5.7         xlsxjars_0.6.1     rJava_0.9-8        MRAtools_0.6.8     stringdist_0.9.4.4 stringr_1.2.0
 [7] stringi_1.1.3      lubridate_1.6.0    data.table_1.10.4  PKI_0.1-3          base64enc_0.1-3    digest_0.6.12
[13] getPass_0.1-1      RPostgreSQL_0.5-1  DBI_0.5-1

loaded via a namespace (and not attached):
[1] magrittr_1.5   rstudioapi_0.6 tools_3.3.2    parallel_3.3.2
</code>```

答:
One month ago is non-defined in this context. February 29th only exists in leap years.

See the lubridate documentation:

Note: Arithmetic with periods can results in undefined behavior when non-existent dates are involved (such as February 29th in non-leap years). Please see Period-class for more details and %m+% and add_with_rollback for alternative operations.

The lubridate package can handle what you are doing, but you need to perform the operaton using %m+%.

Body:
I have a script in which I subset my data according to some set time periods and wanted to subset all the records that had occurred in the last month.

However if I try to subtract one month from today's date it yields an NA:

> today <- Sys.Date()
> today
[1] "2017-03-29"
> today - months(1)
[1] NA

I do have lubridate loaded but I think this calculation is being performed with base R.  If I subtract 2 or more months it works fine:

> today - months(2)
[1] "2017-01-29"
> today - months(3)
[1] "2016-12-29"

Does anyone have any ideas about what might be going on?

UPDATE: I think this is something to do with simple date subtraction not handling leap year cases (2017 is not a leap year so "2017-02-29" does not exist).

Are there other packages / functions that take into account leap years?  For the above example I would expect the answer to revert to the last day of the previous month, i.e.:

today - months(1)
# Should yield:
"2017-02-28"

Would it make sense for this calculation to give the same results for both today and yesterday (or what is the ISO convention for this)?

> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] xlsx_0.5.7         xlsxjars_0.6.1     rJava_0.9-8        MRAtools_0.6.8     stringdist_0.9.4.4 stringr_1.2.0
 [7] stringi_1.1.3      lubridate_1.6.0    data.table_1.10.4  PKI_0.1-3          base64enc_0.1-3    digest_0.6.12
[13] getPass_0.1-1      RPostgreSQL_0.5-1  DBI_0.5-1

loaded via a namespace (and not attached):
[1] magrittr_1.5   rstudioapi_0.6 tools_3.3.2    parallel_3.3.2


来源: stackexchange

问:
Webpack compiles locally, but not on Heroku
My Webpack is compiling properly on my development environment, but once I deploy to Heroku, I'm receiving an error that Chart.js isn't a module- </p>

```<code>remote: -----> npm install --only=dev
remote: webpack-rails-example@0.0.1 /tmp/build_c869c8be2e135052ead9047bc4bb375a
remote: ├── babel@6.23.0
remote: ├─┬ babel-cli@6.24.0
remote: │ ├── babel-polyfill@6.23.0
remote: │ ├─┬ babel-register@6.24.0
remote: │ │ ├─┬ home-or-tmp@2.0.0
remote: │ │ │ ├── os-homedir@1.0.2
remote: │ │ │ └── os-tmpdir@1.0.2
remote: │ │ └── source-map-support@0.4.14
remote: │ ├─┬ chokidar@1.6.1
remote: │ │ ├─┬ anymatch@1.3.0
remote: │ │ │ └── arrify@1.0.1
remote: │ │ ├── async-each@1.0.1
remote: │ │ ├─┬ is-binary-path@1.0.1
remote: │ │ │ └── binary-extensions@1.8.0
remote: │ │ ├─┬ is-glob@2.0.1
remote: │ │ │ └── is-extglob@1.0.0
remote: │ │ └─┬ readdirp@2.1.0
remote: │ │   └── set-immediate-shim@1.0.1
remote: │ ├─┬ commander@2.9.0
remote: │ │ └── graceful-readlink@1.0.1
remote: │ ├── convert-source-map@1.5.0
remote: │ ├── fs-readdir-recursive@1.0.0
remote: │ ├─┬ glob@7.1.1
remote: │ │ ├── fs.realpath@1.0.0
remote: │ │ ├─┬ inflight@1.0.6
remote: │ │ │ └── wrappy@1.0.2
remote: │ │ └── once@1.4.0
remote: │ ├─┬ output-file-sync@1.1.2
remote: │ │ └── graceful-fs@4.1.11
remote: │ ├── slash@1.0.0
remote: │ ├── source-map@0.5.6
remote: │ └─┬ v8flags@2.0.11
remote: │   └── user-home@1.1.1
remote: ├─┬ babel-core@6.24.0
remote: │ ├─┬ babel-code-frame@6.22.0
remote: │ │ ├─┬ chalk@1.1.3
remote: │ │ │ ├── ansi-styles@2.2.1
remote: │ │ │ ├── escape-string-regexp@1.0.5
remote: │ │ │ ├── has-ansi@2.0.0
remote: │ │ │ └── supports-color@2.0.0
remote: │ │ └── esutils@2.0.2
remote: │ ├─┬ babel-generator@6.24.0
remote: │ │ ├─┬ detect-indent@4.0.0
remote: │ │ │ └─┬ repeating@2.0.1
remote: │ │ │   └─┬ is-finite@1.0.2
remote: │ │ │     └── number-is-nan@1.0.1
remote: │ │ ├── jsesc@1.3.0
remote: │ │ └── trim-right@1.0.1
remote: │ ├── babel-helpers@6.23.0
remote: │ ├── babel-messages@6.23.0
remote: │ ├── babel-template@6.23.0
remote: │ ├─┬ babel-traverse@6.23.1
remote: │ │ └── globals@9.17.0
remote: │ ├─┬ babel-types@6.23.0
remote: │ │ └── to-fast-properties@1.0.2
remote: │ ├── babylon@6.16.1
remote: │ ├── json5@0.5.1
remote: │ ├─┬ minimatch@3.0.3
remote: │ │ └─┬ brace-expansion@1.1.6
remote: │ │   ├── balanced-match@0.4.2
remote: │ │   └── concat-map@0.0.1
remote: │ └── private@0.1.7
remote: ├─┬ babel-loader@6.4.1
remote: │ ├─┬ find-cache-dir@0.1.1
remote: │ │ ├── commondir@1.0.1
remote: │ │ └─┬ pkg-dir@1.0.0
remote: │ │   └─┬ find-up@1.1.2
remote: │ │     ├── path-exists@2.1.0
remote: │ │     └─┬ pinkie-promise@2.0.1
remote: │ │       └── pinkie@2.0.4
remote: │ ├─┬ loader-utils@0.2.17
remote: │ │ ├── big.js@3.1.3
remote: │ │ └── emojis-list@2.1.0
remote: │ ├─┬ mkdirp@0.5.1
remote: │ │ └── minimist@0.0.8
remote: │ └── object-assign@4.1.1
remote: ├─┬ babel-preset-react@6.23.0
remote: │ ├── babel-plugin-syntax-jsx@6.18.0
remote: │ ├── babel-plugin-transform-react-display-name@6.23.0
remote: │ ├─┬ babel-plugin-transform-react-jsx@6.23.0
remote: │ │ └── babel-helper-builder-react-jsx@6.23.0
remote: │ ├── babel-plugin-transform-react-jsx-self@6.22.0
remote: │ ├── babel-plugin-transform-react-jsx-source@6.22.0
remote: │ └─┬ babel-preset-flow@6.23.0
remote: │   └─┬ babel-plugin-transform-flow-strip-types@6.22.0
remote: │     └── babel-plugin-syntax-flow@6.18.0
remote: ├─┬ chart.js@2.5.0
remote: │ ├─┬ chartjs-color@2.1.0
remote: │ │ ├─┬ chartjs-color-string@0.4.0
remote: │ │ │ └── color-name@1.1.2
remote: │ │ └── color-convert@0.5.3
remote: │ └── moment@2.18.1
remote: ├─┬ css-loader@0.26.4
remote: │ ├─┬ css-selector-tokenizer@0.7.0
remote: │ │ ├── cssesc@0.1.0
remote: │ │ ├── fastparse@1.1.1
remote: │ │ └─┬ regexpu-core@1.0.0
remote: │ │   ├── regenerate@1.3.2
remote: │ │   ├── regjsgen@0.2.0
remote: │ │   └─┬ regjsparser@0.1.5
remote: │ │     └── jsesc@0.5.0
remote: │ ├─┬ cssnano@3.10.0
remote: │ │ ├─┬ autoprefixer@6.7.7
remote: │ │ │ ├─┬ browserslist@1.7.7
remote: │ │ │ │ └── electron-to-chromium@1.3.2
remote: │ │ │ ├── caniuse-db@1.0.30000646
remote: │ │ │ ├── normalize-range@0.1.2
remote: │ │ │ └── num2fraction@1.2.2
remote: │ │ ├── decamelize@1.2.0
remote: │ │ ├── defined@1.0.0
remote: │ │ ├─┬ has@1.0.1
remote: │ │ │ └── function-bind@1.1.0
remote: │ │ ├─┬ postcss-calc@5.3.1
remote: │ │ │ ├── postcss-message-helpers@2.0.0
remote: │ │ │ └─┬ reduce-css-calc@1.3.0
remote: │ │ │   ├── math-expression-evaluator@1.2.16
remote: │ │ │   └── reduce-function-call@1.0.2
remote: │ │ ├─┬ postcss-colormin@2.2.2
remote: │ │ │ └─┬ colormin@1.1.2
remote: │ │ │   ├─┬ color@0.11.4
remote: │ │ │   │ ├── color-convert@1.9.0
remote: │ │ │   │ └── color-string@0.3.0
remote: │ │ │   └── css-color-names@0.0.4
remote: │ │ ├── postcss-convert-values@2.6.1
remote: │ │ ├── postcss-discard-comments@2.0.4
remote: │ │ ├── postcss-discard-duplicates@2.1.0
remote: │ │ ├── postcss-discard-empty@2.1.0
remote: │ │ ├── postcss-discard-overridden@0.1.1
remote: │ │ ├─┬ postcss-discard-unused@2.2.3
remote: │ │ │ └── uniqs@2.0.0
remote: │ │ ├─┬ postcss-filter-plugins@2.0.2
remote: │ │ │ └─┬ uniqid@4.1.1
remote: │ │ │   └── macaddress@0.2.8
remote: │ │ ├── postcss-merge-idents@2.1.7
remote: │ │ ├── postcss-merge-longhand@2.0.2
remote: │ │ ├─┬ postcss-merge-rules@2.1.2
remote: │ │ │ ├─┬ caniuse-api@1.5.3
remote: │ │ │ │ ├── lodash.memoize@4.1.2
remote: │ │ │ │ └── lodash.uniq@4.5.0
remote: │ │ │ ├─┬ postcss-selector-parser@2.2.3
remote: │ │ │ │ ├── flatten@1.0.2
remote: │ │ │ │ ├── indexes-of@1.0.1
remote: │ │ │ │ └── uniq@1.0.1
remote: │ │ │ └── vendors@1.0.1
remote: │ │ ├── postcss-minify-font-values@1.0.5
remote: │ │ ├── postcss-minify-gradients@1.0.5
remote: │ │ ├─┬ postcss-minify-params@1.2.2
remote: │ │ │ └── alphanum-sort@1.0.2
remote: │ │ ├── postcss-minify-selectors@2.1.1
remote: │ │ ├── postcss-normalize-charset@1.1.1
remote: │ │ ├─┬ postcss-normalize-url@3.0.8
remote: │ │ │ ├── is-absolute-url@2.1.0
remote: │ │ │ └─┬ normalize-url@1.9.1
remote: │ │ │   ├── prepend-http@1.0.4
remote: │ │ │   ├── query-string@4.3.2
remote: │ │ │   └─┬ sort-keys@1.1.2
remote: │ │ │     └── is-plain-obj@1.1.0
remote: │ │ ├── postcss-ordered-values@2.2.3
remote: │ │ ├── postcss-reduce-idents@2.4.0
remote: │ │ ├── postcss-reduce-initial@1.0.1
remote: │ │ ├── postcss-reduce-transforms@1.0.4
remote: │ │ ├─┬ postcss-svgo@2.1.6
remote: │ │ │ ├─┬ is-svg@2.1.0
remote: │ │ │ │ └── html-comment-regex@1.1.1
remote: │ │ │ └─┬ svgo@0.7.2
remote: │ │ │   ├─┬ coa@1.0.1
remote: │ │ │   │ └── q@1.5.0
remote: │ │ │   ├── colors@1.1.2
remote: │ │ │   ├─┬ csso@2.3.2
remote: │ │ │   │ └── clap@1.1.3
remote: │ │ │   ├─┬ js-yaml@3.7.0
remote: │ │ │   │ ├─┬ argparse@1.0.9
remote: │ │ │   │ │ └── sprintf-js@1.0.3
remote: │ │ │   │ └── esprima@2.7.3
remote: │ │ │   ├── sax@1.2.2
remote: │ │ │   └── whet.extend@0.9.9
remote: │ │ ├── postcss-unique-selectors@2.0.2
remote: │ │ ├── postcss-value-parser@3.3.0
remote: │ │ └── postcss-zindex@2.2.0
remote: │ ├── loader-utils@1.1.0
remote: │ ├── lodash.camelcase@4.3.0
remote: │ ├─┬ postcss@5.2.16
remote: │ │ └── js-base64@2.1.9
remote: │ ├── postcss-modules-extract-imports@1.0.1
remote: │ ├─┬ postcss-modules-local-by-default@1.1.1
remote: │ │ └── css-selector-tokenizer@0.6.0
remote: │ ├─┬ postcss-modules-scope@1.0.2
remote: │ │ └── css-selector-tokenizer@0.6.0
remote: │ ├─┬ postcss-modules-values@1.2.2
remote: │ │ └── icss-replace-symbols@1.0.2
remote: │ └── source-list-map@0.1.8
remote: ├─┬ extract-text-webpack-plugin@1.0.1
remote: │ ├── async@1.5.2
remote: │ └── webpack-sources@0.1.5
remote: ├── jquery@3.2.1
remote: ├─┬ react@15.4.2
remote: │ └─┬ fbjs@0.8.11
remote: │   ├── core-js@1.2.7
remote: │   ├─┬ isomorphic-fetch@2.2.1
remote: │   │ ├─┬ node-fetch@1.6.3
remote: │   │ │ ├─┬ encoding@0.1.12
remote: │   │ │ │ └── iconv-lite@0.4.15
remote: │   │ │ └── is-stream@1.1.0
remote: │   │ └── whatwg-fetch@2.0.3
remote: │   ├─┬ promise@7.1.1
remote: │   │ └── asap@2.0.5
remote: │   ├── setimmediate@1.0.5
remote: │   └── ua-parser-js@0.7.12
remote: ├── react-dom@15.4.2
remote: ├─┬ react-search-input@0.10.4
remote: │ └── fuse.js@2.6.2
remote: ├─┬ style-loader@0.13.2
remote: │ └── loader-utils@1.1.0
remote: ├─┬ webpack@1.14.0
remote: │ ├── acorn@3.3.0
remote: │ ├── clone@1.0.2
remote: │ ├─┬ enhanced-resolve@0.9.1
remote: │ │ └── memory-fs@0.2.0
remote: │ ├── interpret@0.6.6
remote: │ ├── memory-fs@0.3.0
remote: │ ├─┬ node-libs-browser@0.7.0
remote: │ │ ├── assert@1.4.1
remote: │ │ ├─┬ browserify-zlib@0.1.4
remote: │ │ │ └── pako@0.2.9
remote: │ │ ├─┬ buffer@4.9.1
remote: │ │ │ ├── base64-js@1.2.0
remote: │ │ │ └── ieee754@1.1.8
remote: │ │ ├─┬ console-browserify@1.1.0
remote: │ │ │ └── date-now@0.1.4
remote: │ │ ├── constants-browserify@1.0.0
remote: │ │ ├─┬ crypto-browserify@3.3.0
remote: │ │ │ ├── browserify-aes@0.4.0
remote: │ │ │ ├── pbkdf2-compat@2.0.1
remote: │ │ │ ├── ripemd160@0.2.0
remote: │ │ │ └── sha.js@2.2.6
remote: │ │ ├── domain-browser@1.1.7
remote: │ │ ├── events@1.1.1
remote: │ │ ├── https-browserify@0.0.1
remote: │ │ ├── os-browserify@0.2.1
remote: │ │ ├── path-browserify@0.0.0
remote: │ │ ├── process@0.11.9
remote: │ │ ├── punycode@1.4.1
remote: │ │ ├── querystring-es3@0.2.1
remote: │ │ ├── stream-browserify@2.0.1
remote: │ │ ├─┬ stream-http@2.6.3
remote: │ │ │ ├── builtin-status-codes@3.0.0
remote: │ │ │ ├── to-arraybuffer@1.0.1
remote: │ │ │ └── xtend@4.0.1
remote: │ │ ├── timers-browserify@2.0.2
remote: │ │ ├── tty-browserify@0.0.0
remote: │ │ ├─┬ url@0.11.0
remote: │ │ │ ├── punycode@1.3.2
remote: │ │ │ └── querystring@0.2.0
remote: │ │ ├─┬ util@0.10.3
remote: │ │ │ └── inherits@2.0.1
remote: │ │ └─┬ vm-browserify@0.0.4
remote: │ │   └── indexof@0.0.1
remote: │ ├── tapable@0.1.10
remote: │ ├─┬ uglify-js@2.7.5
remote: │ │ ├── async@0.2.10
remote: │ │ ├── uglify-to-browserify@1.0.2
remote: │ │ └─┬ yargs@3.10.0
remote: │ │   ├── camelcase@1.2.1
remote: │ │   ├─┬ cliui@2.1.0
remote: │ │   │ ├─┬ center-align@0.1.3
remote: │ │   │ │ ├─┬ align-text@0.1.4
remote: │ │   │ │ │ └── longest@1.0.1
remote: │ │   │ │ └── lazy-cache@1.0.4
remote: │ │   │ ├── right-align@0.1.3
remote: │ │   │ └── wordwrap@0.0.2
remote: │ │   └── window-size@0.1.0
remote: │ ├─┬ watchpack@0.2.9
remote: │ │ └── async@0.9.2
remote: │ └─┬ webpack-core@0.6.9
remote: │   └─┬ source-map@0.4.4
remote: │     └── amdefine@1.0.1
remote: └─┬ webpack-bundle-tracker@0.1.0
remote:   └─┬ strip-ansi@2.0.1
remote:     └── ansi-regex@1.1.1
remote:
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
remote: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
remote: npm WARN webpack-rails-example@0.0.1 No repository field.
remote: -----> bundle exec rake webpack:compile
remote: ** Invoke webpack:compile (first_time)
remote: ** Invoke environment (first_time)
remote: ** Execute environment
remote: ** Execute webpack:compile
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/.bin/webpack --config /tmp/build_c869c8be2e135052ead9047bc4bb375a/config/webpack.config.js --bail
remote: Error
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/webpack/lib/Compilation.js:229:38
remote:     at onDoneResolving (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/webpack/lib/NormalModuleFactory.js:29:20)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/webpack/lib/NormalModuleFactory.js:85:20
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:726:13
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:52:16
remote:     at done (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:241:17)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:44:16
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:723:17
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:167:37
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:24:19
remote:     at onResolved (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:38:18)
remote:     at innerCallback (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:94:11)
remote:     at loggingCallbackWrapper (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/tapable/lib/Tapable.js:134:6
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/ModulesInDirectoriesPlugin.js:54:23
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:191:15
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/ModulesInDirectoriesPlugin.js:45:26
remote:     at loggingCallbackWrapper (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/tapable/lib/Tapable.js:134:6
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:122:33
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:191:15
remote:     at applyPluginsParallelBailResult.createInnerCallback.log (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:110:4)
remote:     at loggingCallbackWrapper (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/tapable/lib/Tapable.js:134:6
remote:     at Resolver.<anonymous> (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/FileAppendPlugin.js:31:26)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:191:15
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/FileAppendPlugin.js:28:12
remote:     at Storage.finished (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/graceful-fs/polyfills.js:284:29
remote:     at FSReqWrap.oncomplete (fs.js:114:15)
remote: resolve module Chart.js in /tmp/build_c869c8be2e135052ead9047bc4bb375a/webpack/js/ui_components/datavisuals
remote:   looking for modules in /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules
remote:     /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js doesn't exist (module as directory)
remote:     resolve 'file' Chart.js in /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules
remote:       resolve file
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js doesn't exist
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js.js doesn't exist
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js.jsx doesn't exist
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js.css doesn't exist
remote: rake aborted!
remote: Command failed with status (1): [/tmp/build_c869c8be2e135052ead9047bc4bb375...]
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/file_utils.rb:66:in `block in create_shell_runner'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/file_utils.rb:56:in `call'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/file_utils.rb:56:in `sh'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/webpack-rails-0.9.9/lib/tasks/webpack.rake:17:in `block (2 levels) in <top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `call'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/rake:23:in `load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/rake:23:in `<top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/bundle:22:in `load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/bundle:22:in `<main>'
remote: Tasks: TOP => webpack:compile
remote:  !     Push rejected, failed to compile webpack-rails app.
remote:
remote:  !     Push failed
</code>```

<p>My webpack config file looks like:
        //
    'use strict';</p>

```<code>var path = require('path');
var webpack = require('webpack');
var StatsPlugin = require('stats-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

// must match config.webpack.dev_server.port
var devServerPort = 3808;

// set NODE_ENV=production on the environment to add asset fingerprints
var production = process.env.NODE_ENV === 'production';

var config = {
  entry: {
    // Sources are expected to live in $app_root/webpack
    application: [
      './webpack/js/application.js',
      './webpack/stylesheets/application.scss'
    ],
    //'instcolors': './webpack/InstColors'
    /*
    dashboard: [
      './webpack/js/index', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs
      './webpack/stylesheets/main.css'
    ],
    ic_contact: './webpack/js/ic_contact', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs
    projects: [
      './webpack/js/ProjectList', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs
      './webpack/stylesheets/main.css'
    ]
    */
  },

  output: {
    // Build assets directly in to public/webpack/, let webpack know
    // that all webpacked assets start with webpack/

    // must match config.webpack.output_dir
    path: path.join(__dirname, '..', 'public', 'webpack'),
    publicPath: '/webpack/',

    filename: production ? '[name]-[chunkhash].js' : '[name].js'
  },

  resolve: {
    root: path.join(__dirname, '..', 'webpack')
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        // This has effect on the react lib size
        'NODE_ENV': JSON.stringify('development'),
      }
    }),
    // must match config.webpack.manifest_filename
    new StatsPlugin('manifest.json', {
      // We only need assetsByChunkName
      chunkModules: false,
      source: false,
      chunks: false,
      modules: false,
      assets: true
    }),
    new ExtractTextPlugin('./webpack/stylesheets/[name].css'),
    new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
  ],
  module: {
    loaders: [
      // to transform JSX into JS
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['react']
        }
      },
      // Extract css files
      {
          test: /\.css$/,
          loader: ExtractTextPlugin.extract("style-loader", "css-loader")
      },

    ],
  },

  resolve: {
    modulesDirectories: ['node_modules', 'bower_components'],
    extensions: ['', '.js', '.jsx', '.css', '.scss']
  },

};

if (production) {
  config.plugins.push(
    new webpack.NoErrorsPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      minimize: false,
      compressor: { warnings: false },
      sourceMap: false
    }),
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify('production') }
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin()
  );
} else {
  config.devServer = {
    port: devServerPort,
    headers: { 'Access-Control-Allow-Origin': '*' }
  };
  config.output.publicPath = '//localhost:' + devServerPort + '/webpack/';
  // Source maps
  config.devtool = 'cheap-module-eval-source-map';
}

module.exports = config;
</code>```

<p>and my package.json-</p>

```<code>{
  "name": "webpack-rails-example",
  "version": "0.0.1",
  "license": "MIT",
  "devDependencies": {
    "babel": "^6.5.2",
    "babel-cli": "^6.18.0",
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.9",
    "babel-preset-react": "^6.16.0"
  },
  "dependencies": {
    "react-bootstrap": "^0.30.7",
    "stats-webpack-plugin": "^0.2.1",
    "react-router": "^2.0.0",
    "webpack-dev-server": "^1.9.0",
    "chart.js": "^2.4.0",
    "css-loader": "^0.26.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "jquery": "*",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-router": "^2.0.0",
    "react-search-input": "^0.10.3",
    "style-loader": "^0.13.1",
    "webpack": "^1.14.0",
    "webpack-bundle-tracker": "^0.1.0"
  },
  "scripts": {
    "start": "webpack-dev-server --config config/webpack.config.js"
  }
}
</code>```

<p>As far as I can tell, it seems that the NPM package is installing, so why can the module not be found? I'm fairly new to React (I'm the backend developer on this project), any help is appreciated.</p>

答:
From the first line in your log: npm install --only=dev it looks like you are only pulling devDependencies.  chart.js is registered in dependencies so using --only=dev will not download chart.js.

To read about the --only switch, here is the documentation.

I would suggest that you remove the --only flag from the npm install if possible.

ContentLicense: CC BY-SA 3.0

Body:
My Webpack is compiling properly on my development environment, but once I deploy to Heroku, I'm receiving an error that Chart.js isn't a module-

remote: -----> npm install --only=dev
remote: webpack-rails-example@0.0.1 /tmp/build_c869c8be2e135052ead9047bc4bb375a
remote: ├── babel@6.23.0
remote: ├─┬ babel-cli@6.24.0
remote: │ ├── babel-polyfill@6.23.0
remote: │ ├─┬ babel-register@6.24.0
remote: │ │ ├─┬ home-or-tmp@2.0.0
remote: │ │ │ ├── os-homedir@1.0.2
remote: │ │ │ └── os-tmpdir@1.0.2
remote: │ │ └── source-map-support@0.4.14
remote: │ ├─┬ chokidar@1.6.1
remote: │ │ ├─┬ anymatch@1.3.0
remote: │ │ │ └── arrify@1.0.1
remote: │ │ ├── async-each@1.0.1
remote: │ │ ├─┬ is-binary-path@1.0.1
remote: │ │ │ └── binary-extensions@1.8.0
remote: │ │ ├─┬ is-glob@2.0.1
remote: │ │ │ └── is-extglob@1.0.0
remote: │ │ └─┬ readdirp@2.1.0
remote: │ │   └── set-immediate-shim@1.0.1
remote: │ ├─┬ commander@2.9.0
remote: │ │ └── graceful-readlink@1.0.1
remote: │ ├── convert-source-map@1.5.0
remote: │ ├── fs-readdir-recursive@1.0.0
remote: │ ├─┬ glob@7.1.1
remote: │ │ ├── fs.realpath@1.0.0
remote: │ │ ├─┬ inflight@1.0.6
remote: │ │ │ └── wrappy@1.0.2
remote: │ │ └── once@1.4.0
remote: │ ├─┬ output-file-sync@1.1.2
remote: │ │ └── graceful-fs@4.1.11
remote: │ ├── slash@1.0.0
remote: │ ├── source-map@0.5.6
remote: │ └─┬ v8flags@2.0.11
remote: │   └── user-home@1.1.1
remote: ├─┬ babel-core@6.24.0
remote: │ ├─┬ babel-code-frame@6.22.0
remote: │ │ ├─┬ chalk@1.1.3
remote: │ │ │ ├── ansi-styles@2.2.1
remote: │ │ │ ├── escape-string-regexp@1.0.5
remote: │ │ │ ├── has-ansi@2.0.0
remote: │ │ │ └── supports-color@2.0.0
remote: │ │ └── esutils@2.0.2
remote: │ ├─┬ babel-generator@6.24.0
remote: │ │ ├─┬ detect-indent@4.0.0
remote: │ │ │ └─┬ repeating@2.0.1
remote: │ │ │   └─┬ is-finite@1.0.2
remote: │ │ │     └── number-is-nan@1.0.1
remote: │ │ ├── jsesc@1.3.0
remote: │ │ └── trim-right@1.0.1
remote: │ ├── babel-helpers@6.23.0
remote: │ ├── babel-messages@6.23.0
remote: │ ├── babel-template@6.23.0
remote: │ ├─┬ babel-traverse@6.23.1
remote: │ │ └── globals@9.17.0
remote: │ ├─┬ babel-types@6.23.0
remote: │ │ └── to-fast-properties@1.0.2
remote: │ ├── babylon@6.16.1
remote: │ ├── json5@0.5.1
remote: │ ├─┬ minimatch@3.0.3
remote: │ │ └─┬ brace-expansion@1.1.6
remote: │ │   ├── balanced-match@0.4.2
remote: │ │   └── concat-map@0.0.1
remote: │ └── private@0.1.7
remote: ├─┬ babel-loader@6.4.1
remote: │ ├─┬ find-cache-dir@0.1.1
remote: │ │ ├── commondir@1.0.1
remote: │ │ └─┬ pkg-dir@1.0.0
remote: │ │   └─┬ find-up@1.1.2
remote: │ │     ├── path-exists@2.1.0
remote: │ │     └─┬ pinkie-promise@2.0.1
remote: │ │       └── pinkie@2.0.4
remote: │ ├─┬ loader-utils@0.2.17
remote: │ │ ├── big.js@3.1.3
remote: │ │ └── emojis-list@2.1.0
remote: │ ├─┬ mkdirp@0.5.1
remote: │ │ └── minimist@0.0.8
remote: │ └── object-assign@4.1.1
remote: ├─┬ babel-preset-react@6.23.0
remote: │ ├── babel-plugin-syntax-jsx@6.18.0
remote: │ ├── babel-plugin-transform-react-display-name@6.23.0
remote: │ ├─┬ babel-plugin-transform-react-jsx@6.23.0
remote: │ │ └── babel-helper-builder-react-jsx@6.23.0
remote: │ ├── babel-plugin-transform-react-jsx-self@6.22.0
remote: │ ├── babel-plugin-transform-react-jsx-source@6.22.0
remote: │ └─┬ babel-preset-flow@6.23.0
remote: │   └─┬ babel-plugin-transform-flow-strip-types@6.22.0
remote: │     └── babel-plugin-syntax-flow@6.18.0
remote: ├─┬ chart.js@2.5.0
remote: │ ├─┬ chartjs-color@2.1.0
remote: │ │ ├─┬ chartjs-color-string@0.4.0
remote: │ │ │ └── color-name@1.1.2
remote: │ │ └── color-convert@0.5.3
remote: │ └── moment@2.18.1
remote: ├─┬ css-loader@0.26.4
remote: │ ├─┬ css-selector-tokenizer@0.7.0
remote: │ │ ├── cssesc@0.1.0
remote: │ │ ├── fastparse@1.1.1
remote: │ │ └─┬ regexpu-core@1.0.0
remote: │ │   ├── regenerate@1.3.2
remote: │ │   ├── regjsgen@0.2.0
remote: │ │   └─┬ regjsparser@0.1.5
remote: │ │     └── jsesc@0.5.0
remote: │ ├─┬ cssnano@3.10.0
remote: │ │ ├─┬ autoprefixer@6.7.7
remote: │ │ │ ├─┬ browserslist@1.7.7
remote: │ │ │ │ └── electron-to-chromium@1.3.2
remote: │ │ │ ├── caniuse-db@1.0.30000646
remote: │ │ │ ├── normalize-range@0.1.2
remote: │ │ │ └── num2fraction@1.2.2
remote: │ │ ├── decamelize@1.2.0
remote: │ │ ├── defined@1.0.0
remote: │ │ ├─┬ has@1.0.1
remote: │ │ │ └── function-bind@1.1.0
remote: │ │ ├─┬ postcss-calc@5.3.1
remote: │ │ │ ├── postcss-message-helpers@2.0.0
remote: │ │ │ └─┬ reduce-css-calc@1.3.0
remote: │ │ │   ├── math-expression-evaluator@1.2.16
remote: │ │ │   └── reduce-function-call@1.0.2
remote: │ │ ├─┬ postcss-colormin@2.2.2
remote: │ │ │ └─┬ colormin@1.1.2
remote: │ │ │   ├─┬ color@0.11.4
remote: │ │ │   │ ├── color-convert@1.9.0
remote: │ │ │   │ └── color-string@0.3.0
remote: │ │ │   └── css-color-names@0.0.4
remote: │ │ ├── postcss-convert-values@2.6.1
remote: │ │ ├── postcss-discard-comments@2.0.4
remote: │ │ ├── postcss-discard-duplicates@2.1.0
remote: │ │ ├── postcss-discard-empty@2.1.0
remote: │ │ ├── postcss-discard-overridden@0.1.1
remote: │ │ ├─┬ postcss-discard-unused@2.2.3
remote: │ │ │ └── uniqs@2.0.0
remote: │ │ ├─┬ postcss-filter-plugins@2.0.2
remote: │ │ │ └─┬ uniqid@4.1.1
remote: │ │ │   └── macaddress@0.2.8
remote: │ │ ├── postcss-merge-idents@2.1.7
remote: │ │ ├── postcss-merge-longhand@2.0.2
remote: │ │ ├─┬ postcss-merge-rules@2.1.2
remote: │ │ │ ├─┬ caniuse-api@1.5.3
remote: │ │ │ │ ├── lodash.memoize@4.1.2
remote: │ │ │ │ └── lodash.uniq@4.5.0
remote: │ │ │ ├─┬ postcss-selector-parser@2.2.3
remote: │ │ │ │ ├── flatten@1.0.2
remote: │ │ │ │ ├── indexes-of@1.0.1
remote: │ │ │ │ └── uniq@1.0.1
remote: │ │ │ └── vendors@1.0.1
remote: │ │ ├── postcss-minify-font-values@1.0.5
remote: │ │ ├── postcss-minify-gradients@1.0.5
remote: │ │ ├─┬ postcss-minify-params@1.2.2
remote: │ │ │ └── alphanum-sort@1.0.2
remote: │ │ ├── postcss-minify-selectors@2.1.1
remote: │ │ ├── postcss-normalize-charset@1.1.1
remote: │ │ ├─┬ postcss-normalize-url@3.0.8
remote: │ │ │ ├── is-absolute-url@2.1.0
remote: │ │ │ └─┬ normalize-url@1.9.1
remote: │ │ │   ├── prepend-http@1.0.4
remote: │ │ │   ├── query-string@4.3.2
remote: │ │ │   └─┬ sort-keys@1.1.2
remote: │ │ │     └── is-plain-obj@1.1.0
remote: │ │ ├── postcss-ordered-values@2.2.3
remote: │ │ ├── postcss-reduce-idents@2.4.0
remote: │ │ ├── postcss-reduce-initial@1.0.1
remote: │ │ ├── postcss-reduce-transforms@1.0.4
remote: │ │ ├─┬ postcss-svgo@2.1.6
remote: │ │ │ ├─┬ is-svg@2.1.0
remote: │ │ │ │ └── html-comment-regex@1.1.1
remote: │ │ │ └─┬ svgo@0.7.2
remote: │ │ │   ├─┬ coa@1.0.1
remote: │ │ │   │ └── q@1.5.0
remote: │ │ │   ├── colors@1.1.2
remote: │ │ │   ├─┬ csso@2.3.2
remote: │ │ │   │ └── clap@1.1.3
remote: │ │ │   ├─┬ js-yaml@3.7.0
remote: │ │ │   │ ├─┬ argparse@1.0.9
remote: │ │ │   │ │ └── sprintf-js@1.0.3
remote: │ │ │   │ └── esprima@2.7.3
remote: │ │ │   ├── sax@1.2.2
remote: │ │ │   └── whet.extend@0.9.9
remote: │ │ ├── postcss-unique-selectors@2.0.2
remote: │ │ ├── postcss-value-parser@3.3.0
remote: │ │ └── postcss-zindex@2.2.0
remote: │ ├── loader-utils@1.1.0
remote: │ ├── lodash.camelcase@4.3.0
remote: │ ├─┬ postcss@5.2.16
remote: │ │ └── js-base64@2.1.9
remote: │ ├── postcss-modules-extract-imports@1.0.1
remote: │ ├─┬ postcss-modules-local-by-default@1.1.1
remote: │ │ └── css-selector-tokenizer@0.6.0
remote: │ ├─┬ postcss-modules-scope@1.0.2
remote: │ │ └── css-selector-tokenizer@0.6.0
remote: │ ├─┬ postcss-modules-values@1.2.2
remote: │ │ └── icss-replace-symbols@1.0.2
remote: │ └── source-list-map@0.1.8
remote: ├─┬ extract-text-webpack-plugin@1.0.1
remote: │ ├── async@1.5.2
remote: │ └── webpack-sources@0.1.5
remote: ├── jquery@3.2.1
remote: ├─┬ react@15.4.2
remote: │ └─┬ fbjs@0.8.11
remote: │   ├── core-js@1.2.7
remote: │   ├─┬ isomorphic-fetch@2.2.1
remote: │   │ ├─┬ node-fetch@1.6.3
remote: │   │ │ ├─┬ encoding@0.1.12
remote: │   │ │ │ └── iconv-lite@0.4.15
remote: │   │ │ └── is-stream@1.1.0
remote: │   │ └── whatwg-fetch@2.0.3
remote: │   ├─┬ promise@7.1.1
remote: │   │ └── asap@2.0.5
remote: │   ├── setimmediate@1.0.5
remote: │   └── ua-parser-js@0.7.12
remote: ├── react-dom@15.4.2
remote: ├─┬ react-search-input@0.10.4
remote: │ └── fuse.js@2.6.2
remote: ├─┬ style-loader@0.13.2
remote: │ └── loader-utils@1.1.0
remote: ├─┬ webpack@1.14.0
remote: │ ├── acorn@3.3.0
remote: │ ├── clone@1.0.2
remote: │ ├─┬ enhanced-resolve@0.9.1
remote: │ │ └── memory-fs@0.2.0
remote: │ ├── interpret@0.6.6
remote: │ ├── memory-fs@0.3.0
remote: │ ├─┬ node-libs-browser@0.7.0
remote: │ │ ├── assert@1.4.1
remote: │ │ ├─┬ browserify-zlib@0.1.4
remote: │ │ │ └── pako@0.2.9
remote: │ │ ├─┬ buffer@4.9.1
remote: │ │ │ ├── base64-js@1.2.0
remote: │ │ │ └── ieee754@1.1.8
remote: │ │ ├─┬ console-browserify@1.1.0
remote: │ │ │ └── date-now@0.1.4
remote: │ │ ├── constants-browserify@1.0.0
remote: │ │ ├─┬ crypto-browserify@3.3.0
remote: │ │ │ ├── browserify-aes@0.4.0
remote: │ │ │ ├── pbkdf2-compat@2.0.1
remote: │ │ │ ├── ripemd160@0.2.0
remote: │ │ │ └── sha.js@2.2.6
remote: │ │ ├── domain-browser@1.1.7
remote: │ │ ├── events@1.1.1
remote: │ │ ├── https-browserify@0.0.1
remote: │ │ ├── os-browserify@0.2.1
remote: │ │ ├── path-browserify@0.0.0
remote: │ │ ├── process@0.11.9
remote: │ │ ├── punycode@1.4.1
remote: │ │ ├── querystring-es3@0.2.1
remote: │ │ ├── stream-browserify@2.0.1
remote: │ │ ├─┬ stream-http@2.6.3
remote: │ │ │ ├── builtin-status-codes@3.0.0
remote: │ │ │ ├── to-arraybuffer@1.0.1
remote: │ │ │ └── xtend@4.0.1
remote: │ │ ├── timers-browserify@2.0.2
remote: │ │ ├── tty-browserify@0.0.0
remote: │ │ ├─┬ url@0.11.0
remote: │ │ │ ├── punycode@1.3.2
remote: │ │ │ └── querystring@0.2.0
remote: │ │ ├─┬ util@0.10.3
remote: │ │ │ └── inherits@2.0.1
remote: │ │ └─┬ vm-browserify@0.0.4
remote: │ │   └── indexof@0.0.1
remote: │ ├── tapable@0.1.10
remote: │ ├─┬ uglify-js@2.7.5
remote: │ │ ├── async@0.2.10
remote: │ │ ├── uglify-to-browserify@1.0.2
remote: │ │ └─┬ yargs@3.10.0
remote: │ │   ├── camelcase@1.2.1
remote: │ │   ├─┬ cliui@2.1.0
remote: │ │   │ ├─┬ center-align@0.1.3
remote: │ │   │ │ ├─┬ align-text@0.1.4
remote: │ │   │ │ │ └── longest@1.0.1
remote: │ │   │ │ └── lazy-cache@1.0.4
remote: │ │   │ ├── right-align@0.1.3
remote: │ │   │ └── wordwrap@0.0.2
remote: │ │   └── window-size@0.1.0
remote: │ ├─┬ watchpack@0.2.9
remote: │ │ └── async@0.9.2
remote: │ └─┬ webpack-core@0.6.9
remote: │   └─┬ source-map@0.4.4
remote: │     └── amdefine@1.0.1
remote: └─┬ webpack-bundle-tracker@0.1.0
remote:   └─┬ strip-ansi@2.0.1
remote:     └── ansi-regex@1.1.1
remote:
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
remote: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
remote: npm WARN webpack-rails-example@0.0.1 No repository field.
remote: -----> bundle exec rake webpack:compile
remote: ** Invoke webpack:compile (first_time)
remote: ** Invoke environment (first_time)
remote: ** Execute environment
remote: ** Execute webpack:compile
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/.bin/webpack --config /tmp/build_c869c8be2e135052ead9047bc4bb375a/config/webpack.config.js --bail
remote: Error
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/webpack/lib/Compilation.js:229:38
remote:     at onDoneResolving (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/webpack/lib/NormalModuleFactory.js:29:20)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/webpack/lib/NormalModuleFactory.js:85:20
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:726:13
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:52:16
remote:     at done (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:241:17)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:44:16
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:723:17
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/async/lib/async.js:167:37
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:24:19
remote:     at onResolved (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:38:18)
remote:     at innerCallback (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:94:11)
remote:     at loggingCallbackWrapper (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/tapable/lib/Tapable.js:134:6
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/ModulesInDirectoriesPlugin.js:54:23
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:191:15
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/ModulesInDirectoriesPlugin.js:45:26
remote:     at loggingCallbackWrapper (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/tapable/lib/Tapable.js:134:6
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:122:33
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:191:15
remote:     at applyPluginsParallelBailResult.createInnerCallback.log (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:110:4)
remote:     at loggingCallbackWrapper (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/createInnerCallback.js:21:19)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/tapable/lib/Tapable.js:134:6
remote:     at Resolver.<anonymous> (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/FileAppendPlugin.js:31:26)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/Resolver.js:191:15
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/FileAppendPlugin.js:28:12
remote:     at Storage.finished (/tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
remote:     at /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/graceful-fs/polyfills.js:284:29
remote:     at FSReqWrap.oncomplete (fs.js:114:15)
remote: resolve module Chart.js in /tmp/build_c869c8be2e135052ead9047bc4bb375a/webpack/js/ui_components/datavisuals
remote:   looking for modules in /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules
remote:     /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js doesn't exist (module as directory)
remote:     resolve 'file' Chart.js in /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules
remote:       resolve file
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js doesn't exist
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js.js doesn't exist
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js.jsx doesn't exist
remote:         /tmp/build_c869c8be2e135052ead9047bc4bb375a/node_modules/Chart.js.css doesn't exist
remote: rake aborted!
remote: Command failed with status (1): [/tmp/build_c869c8be2e135052ead9047bc4bb375...]
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/file_utils.rb:66:in `block in create_shell_runner'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/file_utils.rb:56:in `call'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/file_utils.rb:56:in `sh'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/webpack-rails-0.9.9/lib/tasks/webpack.rake:17:in `block (2 levels) in <top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `call'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/rake:23:in `load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/rake:23:in `<top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/ruby-2.2.3/lib/ruby/gems/2.2.0/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/bundle:22:in `load'
remote: /tmp/build_c869c8be2e135052ead9047bc4bb375a/vendor/bundle/ruby/2.2.0/bin/bundle:22:in `'
remote: Tasks: TOP => webpack:compile
remote:  !     Push rejected, failed to compile webpack-rails app.
remote:
remote:  !     Push failed

My webpack config file looks like:
        //
    'use strict';

var path = require('path');
var webpack = require('webpack');
var StatsPlugin = require('stats-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

// must match config.webpack.dev_server.port
var devServerPort = 3808;

// set NODE_ENV=production on the environment to add asset fingerprints
var production = process.env.NODE_ENV === 'production';

var config = {
  entry: {
    // Sources are expected to live in $app_root/webpack
    application: [
      './webpack/js/application.js',
      './webpack/stylesheets/application.scss'
    ],
    //'instcolors': './webpack/InstColors'
    /*
    dashboard: [
      './webpack/js/index', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs
      './webpack/stylesheets/main.css'
    ],
    ic_contact: './webpack/js/ic_contact', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs
    projects: [
      './webpack/js/ProjectList', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs
      './webpack/stylesheets/main.css'
    ]
    */
  },

  output: {
    // Build assets directly in to public/webpack/, let webpack know
    // that all webpacked assets start with webpack/

    // must match config.webpack.output_dir
    path: path.join(__dirname, '..', 'public', 'webpack'),
    publicPath: '/webpack/',

    filename: production ? '[name]-[chunkhash].js' : '[name].js'
  },

  resolve: {
    root: path.join(__dirname, '..', 'webpack')
  },

  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
        // This has effect on the react lib size
        'NODE_ENV': JSON.stringify('development'),
      }
    }),
    // must match config.webpack.manifest_filename
    new StatsPlugin('manifest.json', {
      // We only need assetsByChunkName
      chunkModules: false,
      source: false,
      chunks: false,
      modules: false,
      assets: true
    }),
    new ExtractTextPlugin('./webpack/stylesheets/[name].css'),
    new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
  ],
  module: {
    loaders: [
      // to transform JSX into JS
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['react']
        }
      },
      // Extract css files
      {
          test: /\.css$/,
          loader: ExtractTextPlugin.extract("style-loader", "css-loader")
      },

    ],
  },

  resolve: {
    modulesDirectories: ['node_modules', 'bower_components'],
    extensions: ['', '.js', '.jsx', '.css', '.scss']
  },

};

if (production) {
  config.plugins.push(
    new webpack.NoErrorsPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      minimize: false,
      compressor: { warnings: false },
      sourceMap: false
    }),
    new webpack.DefinePlugin({
      'process.env': { NODE_ENV: JSON.stringify('production') }
    }),
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin()
  );
} else {
  config.devServer = {
    port: devServerPort,
    headers: { 'Access-Control-Allow-Origin': '*' }
  };
  config.output.publicPath = '//localhost:' + devServerPort + '/webpack/';
  // Source maps
  config.devtool = 'cheap-module-eval-source-map';
}

module.exports = config;

and my package.json-

{
  "name": "webpack-rails-example",
  "version": "0.0.1",
  "license": "MIT",
  "devDependencies": {
    "babel": "^6.5.2",
    "babel-cli": "^6.18.0",
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.9",
    "babel-preset-react": "^6.16.0"
  },
  "dependencies": {
    "react-bootstrap": "^0.30.7",
    "stats-webpack-plugin": "^0.2.1",
    "react-router": "^2.0.0",
    "webpack-dev-server": "^1.9.0",
    "chart.js": "^2.4.0",
    "css-loader": "^0.26.1",
    "extract-text-webpack-plugin": "^1.0.1",
    "jquery": "*",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-router": "^2.0.0",
    "react-search-input": "^0.10.3",
    "style-loader": "^0.13.1",
    "webpack": "^1.14.0",
    "webpack-bundle-tracker": "^0.1.0"
  },
  "scripts": {
    "start": "webpack-dev-server --config config/webpack.config.js"
  }
}

As far as I can tell, it seems that the NPM package is installing, so why can the module not be found? I'm fairly new to React (I'm the backend developer on this project), any help is appreciated.


问:
Borders in stacked bar chart are being overplotted by the bars
I’m trying to make a stacked bar chart, where some of the bars get a black boarder and others don’t. To accomplish this, I set the color depending on the variable choose. When it’s true, the boarder is black, otherwise it’s transparent.

The Problem: When the first bar has a boarder, the right edge of the boarder gets overplotted by the second bar.

Here is my code and an image of the problem:

```<code>    #Sample Data
    Var1 <- rep(c("A1","A2"),4)
    Var2 <- c("Q1","Q1","Q2","Q2","Q3","Q3","Q4","Q4")
    Freq <- c(4,2,6,2,6,4,9,3)
    choose <- c(F,F,T,F,F,T,F,T)

    df <- as.data.frame(cbind(Var1,Var2, Freq,choose))

    g<- ggplot(df, aes(x=factor(Var2), y=Freq))+
      geom_bar(stat="identity", aes(fill = Var1, color = choose), size = 3) +
      scale_color_manual(values = c('FALSE' = 'transparent', 'TRUE' = 'black'))+
      coord_flip()

    g
</code>```

I tried to fix it, by drawing the boarder after the bars with fill = NA, this does draw the boarders on top of the bars, but not at the right position.

```<code>    g<- ggplot(df, aes(x=factor(Var2), y=Freq))+
      scale_color_manual(values = c('FALSE' = 'transparent', 'TRUE' = 'black'))+
      geom_bar(stat="identity", aes(fill = Var1))+
      geom_bar(stat="identity", aes(color = choose),  fill = NA, size = 3)+
      coord_flip()

    g
</code>```

Any ideas how to fix this?

答:
Map Var1 to the group aesthetic to get things stacked in your second geom_bar.

```<code>ggplot(df, aes(x=factor(Var2), y=Freq))+
    scale_color_manual(values = c('FALSE' = 'transparent', 'TRUE' = 'black'))+
    geom_bar(stat="identity", aes(fill = Var1))+
    geom_bar(stat="identity", aes(color = choose, group = Var1),  fill = NA, size = 3)+
    coord_flip()
</code>```

Body:
I’m trying to make a stacked bar chart, where some of the bars get a black boarder and others don’t. To accomplish this, I set the color depending on the variable choose. When it’s true, the boarder is black, otherwise it’s transparent.

The Problem: When the first bar has a boarder, the right edge of the boarder gets overplotted by the second bar.

Here is my code and an image of the problem:

    #Sample Data
    Var1 <- rep(c("A1","A2"),4)
    Var2 <- c("Q1","Q1","Q2","Q2","Q3","Q3","Q4","Q4")
    Freq <- c(4,2,6,2,6,4,9,3)
    choose <- c(F,F,T,F,F,T,F,T)

    df <- as.data.frame(cbind(Var1,Var2, Freq,choose))

    g<- ggplot(df, aes(x=factor(Var2), y=Freq))+
      geom_bar(stat="identity", aes(fill = Var1, color = choose), size = 3) +
      scale_color_manual(values = c('FALSE' = 'transparent', 'TRUE' = 'black'))+
      coord_flip()

    g

I tried to fix it, by drawing the boarder after the bars with fill = NA, this does draw the boarders on top of the bars, but not at the right position.

    g<- ggplot(df, aes(x=factor(Var2), y=Freq))+
      scale_color_manual(values = c('FALSE' = 'transparent', 'TRUE' = 'black'))+
      geom_bar(stat="identity", aes(fill = Var1))+
      geom_bar(stat="identity", aes(color = choose),  fill = NA, size = 3)+
      coord_flip()

    g

Any ideas how to fix this?

Body:
Map Var1 to the group aesthetic to get things stacked in your second geom_bar.

ggplot(df, aes(x=factor(Var2), y=Freq))+
    scale_color_manual(values = c('FALSE' = 'transparent', 'TRUE' = 'black'))+
    geom_bar(stat="identity", aes(fill = Var1))+
    geom_bar(stat="identity", aes(color = choose, group = Var1),  fill = NA, size = 3)+
    coord_flip()


问:
Android WhisperSystems/libsignal-service
I am using WhisperSystems/libsignal-service library in android but I am getting one issue, I am not able to add library in my project. It is not taking lib version code, and on the WhisperSystems site also the not mentioned this things.

答:
Looks like you were trying to get here.

```<code>https://repo1.maven.org/maven2/org/whispersystems/signal-service-android/2.3.0
</code>```

You therefore need this section in your Gradle file.

```<code>repositories {
    maven {
        url "https://repo1.maven.org/maven2/"
    }
    jcenter()
</code>```

You can see the full example here

 https://github.com/WhisperSystems/Signal-Android/blob/master/build.gradle

Latest version appears to be 2.5.4, by the way

Body:
Looks like you were trying to get here.

https://repo1.maven.org/maven2/org/whispersystems/signal-service-android/2.3.0

You therefore need this section in your Gradle file.

repositories {
    maven {
        url "https://repo1.maven.org/maven2/"
    }
    jcenter()

You can see the full example here

 https://github.com/WhisperSystems/Signal-Android/blob/master/build.gradle

Latest version appears to be 2.5.4, by the way


答:
The calculation of months is indeed perfomed by base R but not the way your think. Months is used to get the month of a date object.

```<code>#Example
today <- Sys.Date()
months(today)
[1] "March"
</code>```

To add or substract months, you should use %m+% from lubridate:

```<code>today <- Sys.Date()
today %m+% months(-1)
[1] "2017-02-28"
</code>```

Title: R subtracting 1 month from today's date gives NA

Body:
The calculation of months is indeed perfomed by base R but not the way your think. Months is used to get the month of a date object.

#Example
today <- Sys.Date()
months(today)
[1] "March"

To add or substract months, you should use %m+% from lubridate:

today <- Sys.Date()
today %m+% months(-1)
[1] "2017-02-28"


问:
angular 4 and ng-template
I'm getting this warning:

```<code>The <template> element is deprecated. Use <ng-template> instead ("
        [attr.tabIndex]="-1"
        [ngClass]="{'k-item': true}">
        [WARNING ->]<template *ngIf="template"
            [templateContext]="{
</code>```

when using angular 4,
is this being taken care of for the release version?

thanks

答:
The problem might also not be in your code. For instance if you are using the last beta release of @angular/material@2.0.0-beta.2, you will get these when you use certain material components.

If that is the origin of your messages, fear not... a new material release that fixes this is said to be dropping any day now.

It needs to be said, also, that what you're seeing are deprecation warnings that will not produce errors in your application. But they are things that need to be corrected before migrating to the next major release.

Title: angular 4 and ng-template

Body:
I'm getting this warning:

The <template> element is deprecated. Use <ng-template> instead ("
        [attr.tabIndex]="-1"
        [ngClass]="{'k-item': true}">
        [WARNING ->]<template *ngIf="template"
            [templateContext]="{

when using angular 4,
is this being taken care of for the release version?

thanks


问:
Why nav-tabs cannot be used with nav-stacked?
Why this case is invalid ?</p>

```<code><ul class="nav nav-tabs nav-stacked" role="tablist">
 <li> ... </li>
 <li> ... </li>
</ul>
</code>```

答:
Only pills are stacked, because tabs have special left/right/top borders to look like tabs. They used to exist in 2.x as tabs-left and tabs-right, but they were removed from 3.x.

See my answer here:

Stacked Tabs in Bootstrap 3

Body:
Why this case is invalid ?

 ...

 ...


问:
Can a class member function template be virtual?
I have heard that C++ class member function templates can't be virtual.  Is this true?

If they can be virtual, what is an example of a scenario in which one would use such a function?

答:
There is a workaround for 'virtual template method' if set of types for the template method is known in advance.

To show the idea, in the example below only two types are used (int and double).

There, a 'virtual' template method (Base::Method) calls corresponding virtual method (one of Base::VMethod) which, in turn, calls template method implementation (Impl::TMethod).

One only needs to implement template method TMethod in derived implementations (AImpl, BImpl) and use Derived<*Impl>.

```<code>class Base
{
public:
    virtual ~Base()
    {
    }

    template <typename T>
    T Method(T t)
    {
        return VMethod(t);
    }

private:
    virtual int VMethod(int t) = 0;
    virtual double VMethod(double t) = 0;
};

template <class Impl>
class Derived : public Impl
{
public:
    template <class... TArgs>
    Derived(TArgs&&... args)
        : Impl(std::forward<TArgs>(args)...)
    {
    }

private:
    int VMethod(int t) final
    {
        return Impl::TMethod(t);
    }

    double VMethod(double t) final
    {
        return Impl::TMethod(t);
    }
};

class AImpl : public Base
{
protected:
    AImpl(int p)
        : i(p)
    {
    }

    template <typename T>
    T TMethod(T t)
    {
        return t - i;
    }

private:
    int i;
};

using A = Derived<AImpl>;

class BImpl : public Base
{
protected:
    BImpl(int p)
        : i(p)
    {
    }

    template <typename T>
    T TMethod(T t)
    {
        return t + i;
    }

private:
    int i;
};

using B = Derived<BImpl>;

int main(int argc, const char* argv[])
{
    A a(1);
    B b(1);
    Base* base = nullptr;

    base = &a;
    std::cout << base->Method(1) << std::endl;
    std::cout << base->Method(2.0) << std::endl;

    base = &b;
    std::cout << base->Method(1) << std::endl;
    std::cout << base->Method(2.0) << std::endl;
}
</code>```

Output:

```<code>0
1
2
3
</code>```

NB:
Base::Method is actually surplus for real code (VMethod can be made public and used directly).
I added it so it looks like as an actual 'virtual' template method.

ContentLicense: CC BY-SA 4.0

Body:
There is a workaround for 'virtual template method' if set of types for the template method is known in advance.

To show the idea, in the example below only two types are used (int and double).

There, a 'virtual' template method (Base::Method) calls corresponding virtual method (one of Base::VMethod) which, in turn, calls template method implementation (Impl::TMethod).

One only needs to implement template method TMethod in derived implementations (AImpl, BImpl) and use Derived<*Impl>.

class Base
{
public:
    virtual ~Base()
    {
    }

    template <typename T>
    T Method(T t)
    {
        return VMethod(t);
    }

private:
    virtual int VMethod(int t) = 0;
    virtual double VMethod(double t) = 0;
};

template <class Impl>
class Derived : public Impl
{
public:
    template <class... TArgs>
    Derived(TArgs&&... args)
        : Impl(std::forward<TArgs>(args)...)
    {
    }

private:
    int VMethod(int t) final
    {
        return Impl::TMethod(t);
    }

    double VMethod(double t) final
    {
        return Impl::TMethod(t);
    }
};

class AImpl : public Base
{
protected:
    AImpl(int p)
        : i(p)
    {
    }

    template <typename T>
    T TMethod(T t)
    {
        return t - i;
    }

private:
    int i;
};

using A = Derived<AImpl>;

class BImpl : public Base
{
protected:
    BImpl(int p)
        : i(p)
    {
    }

    template <typename T>
    T TMethod(T t)
    {
        return t + i;
    }

private:
    int i;
};

using B = Derived<BImpl>;

int main(int argc, const char* argv[])
{
    A a(1);
    B b(1);
    Base* base = nullptr;

    base = &a;
    std::cout << base->Method(1) << std::endl;
    std::cout << base->Method(2.0) << std::endl;

    base = &b;
    std::cout << base->Method(1) << std::endl;
    std::cout << base->Method(2.0) << std::endl;
}

Output:

0
1
2
3

NB:
Base::Method is actually surplus for real code (VMethod can be made public and used directly).
I added it so it looks like as an actual 'virtual' template method.


问:
iPhone sdk in Linux
I have seen many threads about developing apps for ipod and iphone on linux and windows. I have seen ones saying that you need jailbreak your device, and I have seen ones that say you don't need to, but you don't have an emulator. I have an ipod touch, but I would prefer to not jailbreak it. Is there any possible way to develop for it? I don't plan to submit anything to the app store, but I do hope to be able to debug the things on my device.</p>

答: In order to codesign an app such that it can be installed on a current iOS device running the stock OS, you pretty much need an Intel Mac running Snow Leopard plus Apple's iOS SDK tools (or access to such) and an iOS Developer enrollment (or "borrowed" certificates or team membership).</p>

ContentLicense: CC BY-SA 2.5

Title: iPhone sdk in Linux


问:
How do I create multiple strings from one string?
I want to filter out all the sections of numbers of a string and add them all to a list of strings.

So from: ["2931741444","2931789497","2931745064","2931763896","2931728251","2931786984","2931799607","293177823","2931795568","293171105"]

to

```<code>list.Add(2931741444);
list.Add(2931789497);
list.Add(2931745064);
</code>```

etc...

I loop through the string, look at where the numbers began and add them to a new string, but I'm stuck now. Here's my attempt:

static void Main(string[] args)
        {

```<code>        using (WebClient wc = new WebClient())
        {
            var json = wc.DownloadString("http://api.hivemc.com/v1/game/SG/data");
            Console.WriteLine(json);
            Console.WriteLine("Was called first.");

            int counter = 2;
            string newString = "";
            string s = json.ToString();
            // loop through the string
            for (int i=0; i < s.Length; i++)
            {

                if (s[i].ToString() == "\"")
                {
                    counter++;
                }

                if (counter.isEven)
                {
                    newString = newString + i;
                }
            }
        }

        Console.ReadKey();
    }
</code>```

Is there an easier way to do this? I also can't see how I would do the other strings with this code.

答:
I think what you're trying to do is deserialization. You can use Json.NET

```<code>var list = new List<long>();
using (var wc = new WebClient())
{
    var json = wc.DownloadString("http://api.hivemc.com/v1/game/SG/data");
    list = JsonConvert.DeserializeObject<List<long>>(json);
}
</code>```

Body:
I want to filter out all the sections of numbers of a string and add them all to a list of strings.

So from: ["2931741444","2931789497","2931745064","2931763896","2931728251","2931786984","2931799607","293177823","2931795568","293171105"]

to

list.Add(2931741444);
list.Add(2931789497);
list.Add(2931745064);

etc...

I loop through the string, look at where the numbers began and add them to a new string, but I'm stuck now. Here's my attempt:

static void Main(string[] args)
        {

        using (WebClient wc = new WebClient())
        {
            var json = wc.DownloadString("http://api.hivemc.com/v1/game/SG/data");
            Console.WriteLine(json);
            Console.WriteLine("Was called first.");

            int counter = 2;
            string newString = "";
            string s = json.ToString();
            // loop through the string
            for (int i=0; i < s.Length; i++)
            {

                if (s[i].ToString() == "\"")
                {
                    counter++;
                }

                if (counter.isEven)
                {
                    newString = newString + i;
                }
            }
        }

        Console.ReadKey();
    }

Is there an easier way to do this? I also can't see how I would do the other strings with this code.

Body:
I think what you're trying to do is deserialization. You can use Json.NET

var list = new List<long>();
using (var wc = new WebClient())
{
    var json = wc.DownloadString("http://api.hivemc.com/v1/game/SG/data");
    list = JsonConvert.DeserializeObject<List<long>>(json);
}


问:
DrawableLeft in center with text
I can't center my drawableLeft icon.

I can easily put icon on the left of text, but if I set gravity to center, then only text is centered, but no icon.

```<code><Button
    android:id="@+id/patient_list_button"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/patientList"
    android:drawableLeft="@drawable/ic_icon_two_heads"
    android:layout_marginBottom="15dp"
    style="@style/darkBlueButtonWithImage"/>
</code>```

This is what I want:

This is what I have:

```<code><style name="darkBlueButtonWithImage">
    <item name="android:drawablePadding">10dp</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:paddingLeft">10dp</item>
    <item name="android:background">@drawable/radius_dark_blue_button</item>
    <item name="android:gravity">center_vertical|left</item>
    <item name="android:drawableTint">@color/white</item> <!-- has to be set in activity.java -->
</style>
</code>```

How can I achieve this?

答:
After giving Google's approach a try over 9000 times, I almost always ended up using a ViewGroup to put both side by side, particularly a RelativeLayout or LinearLayout and then adding an ImageView and a TextView. It's lame, but drawableStart/End have so many missing features that you'll waste a lot of time before you realize "you can't do it".

Alignments, tinting, Vectors, etc. All those things are harder or impossible with the "built in" drawable.

Title: DrawableLeft in center with text

Body:
I can't center my drawableLeft icon.

I can easily put icon on the left of text, but if I set gravity to center, then only text is centered, but no icon.

<Button
    android:id="@+id/patient_list_button"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/patientList"
    android:drawableLeft="@drawable/ic_icon_two_heads"
    android:layout_marginBottom="15dp"
    style="@style/darkBlueButtonWithImage"/>

This is what I want:

This is what I have:

How can I achieve this?


问:
Adding to Dictionary inside a For Loop
I'm working with a swift playground for a project at Treehouse. I'm having trouble with adding an additional key:value pair to a dictionary inside of a for loop. Here is the code that I have:

```<code>var counter = 0
for (var player) in experiencedPlayers {
counter += 1
if counter % 3 == 0 {
    for team in 1...3 {
        switch team {
            case 1:
                teamSharks.append(player)
                player["Team"] = "Sharks"
            case 2:
                teamDragons.append(player)
                player["Team"] = "Dragons"
            case 3:
                teamRaptors.append(player)
                player["Team"] = "Raptors"
            default: break
            }
        }
    }
}
</code>```

This method does not error out, but it should be adding "Team": "Sharks", etc. to the player's dictionary but it is not. Any suggestions?

答: Because player is declared inside the scope in your for..in only. So as soon as you try to modify it it will work only inside this scope, it's like a copy. If you want to modify you need to reassign your player in your experiencedPlayers with your modified object</p>

Title: Adding to Dictionary inside a For Loop

Body:
I'm working with a swift playground for a project at Treehouse. I'm having trouble with adding an additional key:value pair to a dictionary inside of a for loop. Here is the code that I have:

var counter = 0
for (var player) in experiencedPlayers {
counter += 1
if counter % 3 == 0 {
    for team in 1...3 {
        switch team {
            case 1:
                teamSharks.append(player)
                player["Team"] = "Sharks"
            case 2:
                teamDragons.append(player)
                player["Team"] = "Dragons"
            case 3:
                teamRaptors.append(player)
                player["Team"] = "Raptors"
            default: break
            }
        }
    }
}

This method does not error out, but it should be adding "Team": "Sharks", etc. to the player's dictionary but it is not. Any suggestions?


问:
Tensorflow: Incompatible shapes when making a custom activation function?
I am trying to build a neural network using custom activation functions. I followed the solution given here, and it works when the input and output vectors have the same size, but not when using different sizes (like in a pooling function). Here is my problem so far:

I am trying to generalize this to the case when the input and the output have different sizes. In my code the input 'x' is of size (2,4), the output 'y' is of size (1,2), and the activation function MEX(.) does the mapping y = MEX(x). I have computed the gradient of MEX() as d_MEX(), where d_MEX(x) has the same size as 'x', that is (2,4). Nevertheless, I get this error

InvalidArgumentError (see above for traceback): Incompatible shapes: [1,2] vs. [2,4]

Shouldn't the gradient of MEX(x) be of the same size as x? Here is my complete code:

```<code>import tensorflow as tf
import numpy as np

# This is our target function
def MEX(x):
    '''
    :param x: is a row vector which is the concatenation of [input, beta]
    :return MEX_{beta}(x): scalar output
    '''
    # lenx = np.size(x) # Number of columns (ROW vector)

    lenx = x.shape[1]
    N = x.shape[0]

    out = np.zeros((1,N))
    for ii in range(N):
        c = x[ii,0:lenx-1]
        beta = x[ii,lenx-1]
        out[0,ii] = 1./beta * np.log( np.mean( np.exp(beta*c) ))
    return np.array(out)

# Now we should write its derivative.
def d_MEX(x):
    # lenx = np.size(x) # Number of
    lenx = x.shape[1]
    N = x.shape[0]

    out = np.zeros((N,lenx))
    for ii in range(N):
        c = x[ii,0:lenx-1]
        beta = x[ii,lenx-1]

        d_beta = np.array([0.])
        d_beta[0] = -1./beta*( MEX(np.array([x[ii,:]])) - np.mean( np.multiply( c, np.exp(beta*c)))/np.mean( np.exp(beta*c))  )
        d_c = 1./lenx*np.exp(beta*c) /np.mean( np.exp(beta*c))
        out[ii,:] = np.concatenate((d_c,d_beta), axis=0)

    return out

# The first step is making it into a numpy function, this is easy:
np_MEX = np.vectorize(MEX, excluded=['x']) # IMPORTANT!! Otherwise np.vectorize() doesnt work
np_d_MEX = np.vectorize(d_MEX, excluded=['x']) # IMPORTANT!! Otherwise np.vectorize() doesnt work

# Now we make a tensforflow function
'''
Making a numpy fct to a tensorflow fct: We will start by making np_d_MEX_32 into a tensorflow function.
There is a function in tensorflow tf.py_func(func, inp, Tout, stateful=stateful, name=name) [doc]
which transforms any numpy function to a tensorflow function, so we can use it:
'''
np_d_MEX_32 = lambda x: np_d_MEX(x=x).astype(np.float32)

def tf_d_MEX(x,name=None):
    with tf.name_scope(name, "d_MEX", [x]) as name:
        y = tf.py_func(np_d_MEX_32,
                        [x],
                        [tf.float32],
                        name=name,
                        stateful=False)
        return y[0]

'''
tf.py_func acts on lists of tensors (and returns a list of tensors), that is why we have [x] (and return y[0]).
The stateful option is to tell tensorflow whether the function always gives the same output for the same input (stateful = False)
in which case tensorflow can simply the tensorflow graph, this is our case and will probably be the case in most situations.
One thing to be careful of at this point is that numpy used float64 but tensorflow uses float32 so you need to convert
your function to use float32 before you can convert it to a tensorflow function otherwise tensorflow will complain.
This is why we need to make np_d_MEX_32 first.

What about the Gradients? The problem with only doing the above is that even though we now have tf_d_MEX which is the
tensorflow version of np_d_MEX, we couldn't use it as an activation function if we wanted to because tensorflow doesn't
know how to calculate the gradients of that function.

Hack to get Gradients: As explained in the sources mentioned above, there is a hack to define gradients of a function
using tf.RegisterGradient [doc] and tf.Graph.gradient_override_map [doc]. Copying the code from harpone we can modify
the tf.py_func function to make it define the gradient at the same time:
'''

def py_func(func, inp, Tout, stateful=True, name=None, grad=None):

    # Need to generate a unique name to avoid duplicates:
    rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8))

    tf.RegisterGradient(rnd_name)(grad)  # see _MySquareGrad for grad example
    g = tf.get_default_graph()
    with g.gradient_override_map({"PyFunc": rnd_name}):
        return tf.py_func(func, inp, Tout, stateful=stateful, name=name)

'''
Now we are almost done, the only thing is that the grad function we need to pass to the above py_func function needs to
 take a special form. It needs to take in an operation, and the previous gradients before the operation and propagate
 the gradients backward after the operation.

Gradient Function: So for our MEX activation function that is how we would do it:
'''

def MEXgrad(op, grad):
    x = op.inputs[0]
    # x = op

    n_gr = tf_d_MEX(x)
    return grad * n_gr

'''
The activation function has only one input, that is why x = op.inputs[0]. If the operation had many inputs, we would
need to return a tuple, one gradient for each input. For example if the operation was a-bthe gradient with respect to a
is +1 and with respect to b is -1 so we would have return +1*grad,-1*grad. Notice that we need to return tensorflow
functions of the input, that is why need tf_d_MEX, np_d_MEX would not have worked because it cannot act on
tensorflow tensors. Alternatively we could have written the derivative using tensorflow functions:
'''

# Combining it all together: Now that we have all the pieces, we can combine them all together:

np_MEX_32 = lambda x: np_MEX(x=x).astype(np.float32)

def tf_MEX(x, name=None):

    with tf.name_scope(name, "MEX",[x]) as name:
        y = py_func(np_MEX_32,
                        [x],
                        [tf.float32],
                        name=name,
                        grad=MEXgrad)  # <-- here's the call to the gradient
        return y[0]

with tf.Session() as sess:

    x = tf.constant([[0.2,0.7,1.2,1.7],[0.2,0.7,1.2,1.7]])
    y = tf_MEX(x)
    tf.global_variables_initializer().run()

    print(x.eval(), y.eval(), tf.gradients(y, [x])[0].eval())
</code>```

In the console, I have checked that the variables have the "correct" shapes:

```<code>x.eval()
Out[9]:
array([[ 0.2       ,  0.69999999,  1.20000005,  1.70000005],
       [ 0.2       ,  0.69999999,  1.20000005,  1.70000005]], dtype=float32)
y.eval()
Out[10]: array([[ 0.83393127,  0.83393127]], dtype=float32)
tf_d_MEX(x).eval()
Out[11]:
array([[ 0.0850958 ,  0.19909413,  0.46581003,  0.07051659],
       [ 0.0850958 ,  0.19909413,  0.46581003,  0.07051659]], dtype=float32)
</code>```

答:
My bad, I just found the mistake.

Its here:

```<code>def MEXgrad(op, grad):
    x = op.inputs[0]
    # x = op

    n_gr = tf_d_MEX(x)
    return n_gr
</code>```

I wonder if there is a typo here, where this mistake is also there.

Body:
I am trying to build a neural network using custom activation functions. I followed the solution given here, and it works when the input and output vectors have the same size, but not when using different sizes (like in a pooling function). Here is my problem so far:

I am trying to generalize this to the case when the input and the output have different sizes. In my code the input 'x' is of size (2,4), the output 'y' is of size (1,2), and the activation function MEX(.) does the mapping y = MEX(x). I have computed the gradient of MEX() as d_MEX(), where d_MEX(x) has the same size as 'x', that is (2,4). Nevertheless, I get this error

InvalidArgumentError (see above for traceback): Incompatible shapes: [1,2] vs. [2,4]

Shouldn't the gradient of MEX(x) be of the same size as x? Here is my complete code:

import tensorflow as tf
import numpy as np

# This is our target function
def MEX(x):
    '''
    :param x: is a row vector which is the concatenation of [input, beta]
    :return MEX_{beta}(x): scalar output
    '''
    # lenx = np.size(x) # Number of columns (ROW vector)

    lenx = x.shape[1]
    N = x.shape[0]

    out = np.zeros((1,N))
    for ii in range(N):
        c = x[ii,0:lenx-1]
        beta = x[ii,lenx-1]
        out[0,ii] = 1./beta * np.log( np.mean( np.exp(beta*c) ))
    return np.array(out)

# Now we should write its derivative.
def d_MEX(x):
    # lenx = np.size(x) # Number of
    lenx = x.shape[1]
    N = x.shape[0]

    out = np.zeros((N,lenx))
    for ii in range(N):
        c = x[ii,0:lenx-1]
        beta = x[ii,lenx-1]

        d_beta = np.array([0.])
        d_beta[0] = -1./beta*( MEX(np.array([x[ii,:]])) - np.mean( np.multiply( c, np.exp(beta*c)))/np.mean( np.exp(beta*c))  )
        d_c = 1./lenx*np.exp(beta*c) /np.mean( np.exp(beta*c))
        out[ii,:] = np.concatenate((d_c,d_beta), axis=0)

    return out

# The first step is making it into a numpy function, this is easy:
np_MEX = np.vectorize(MEX, excluded=['x']) # IMPORTANT!! Otherwise np.vectorize() doesnt work
np_d_MEX = np.vectorize(d_MEX, excluded=['x']) # IMPORTANT!! Otherwise np.vectorize() doesnt work

# Now we make a tensforflow function
'''
Making a numpy fct to a tensorflow fct: We will start by making np_d_MEX_32 into a tensorflow function.
There is a function in tensorflow tf.py_func(func, inp, Tout, stateful=stateful, name=name) [doc]
which transforms any numpy function to a tensorflow function, so we can use it:
'''
np_d_MEX_32 = lambda x: np_d_MEX(x=x).astype(np.float32)

def tf_d_MEX(x,name=None):
    with tf.name_scope(name, "d_MEX", [x]) as name:
        y = tf.py_func(np_d_MEX_32,
                        [x],
                        [tf.float32],
                        name=name,
                        stateful=False)
        return y[0]

'''
tf.py_func acts on lists of tensors (and returns a list of tensors), that is why we have [x] (and return y[0]).
The stateful option is to tell tensorflow whether the function always gives the same output for the same input (stateful = False)
in which case tensorflow can simply the tensorflow graph, this is our case and will probably be the case in most situations.
One thing to be careful of at this point is that numpy used float64 but tensorflow uses float32 so you need to convert
your function to use float32 before you can convert it to a tensorflow function otherwise tensorflow will complain.
This is why we need to make np_d_MEX_32 first.

What about the Gradients? The problem with only doing the above is that even though we now have tf_d_MEX which is the
tensorflow version of np_d_MEX, we couldn't use it as an activation function if we wanted to because tensorflow doesn't
know how to calculate the gradients of that function.

Hack to get Gradients: As explained in the sources mentioned above, there is a hack to define gradients of a function
using tf.RegisterGradient [doc] and tf.Graph.gradient_override_map [doc]. Copying the code from harpone we can modify
the tf.py_func function to make it define the gradient at the same time:
'''

def py_func(func, inp, Tout, stateful=True, name=None, grad=None):

    # Need to generate a unique name to avoid duplicates:
    rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8))

    tf.RegisterGradient(rnd_name)(grad)  # see _MySquareGrad for grad example
    g = tf.get_default_graph()
    with g.gradient_override_map({"PyFunc": rnd_name}):
        return tf.py_func(func, inp, Tout, stateful=stateful, name=name)

'''
Now we are almost done, the only thing is that the grad function we need to pass to the above py_func function needs to
 take a special form. It needs to take in an operation, and the previous gradients before the operation and propagate
 the gradients backward after the operation.

Gradient Function: So for our MEX activation function that is how we would do it:
'''

def MEXgrad(op, grad):
    x = op.inputs[0]
    # x = op

    n_gr = tf_d_MEX(x)
    return grad * n_gr

'''
The activation function has only one input, that is why x = op.inputs[0]. If the operation had many inputs, we would
need to return a tuple, one gradient for each input. For example if the operation was a-bthe gradient with respect to a
is +1 and with respect to b is -1 so we would have return +1*grad,-1*grad. Notice that we need to return tensorflow
functions of the input, that is why need tf_d_MEX, np_d_MEX would not have worked because it cannot act on
tensorflow tensors. Alternatively we could have written the derivative using tensorflow functions:
'''

# Combining it all together: Now that we have all the pieces, we can combine them all together:

np_MEX_32 = lambda x: np_MEX(x=x).astype(np.float32)

def tf_MEX(x, name=None):

    with tf.name_scope(name, "MEX",[x]) as name:
        y = py_func(np_MEX_32,
                        [x],
                        [tf.float32],
                        name=name,
                        grad=MEXgrad)  # <-- here's the call to the gradient
        return y[0]

with tf.Session() as sess:

    x = tf.constant([[0.2,0.7,1.2,1.7],[0.2,0.7,1.2,1.7]])
    y = tf_MEX(x)
    tf.global_variables_initializer().run()

    print(x.eval(), y.eval(), tf.gradients(y, [x])[0].eval())

In the console, I have checked that the variables have the "correct" shapes:

x.eval()
Out[9]:
array([[ 0.2       ,  0.69999999,  1.20000005,  1.70000005],
       [ 0.2       ,  0.69999999,  1.20000005,  1.70000005]], dtype=float32)
y.eval()
Out[10]: array([[ 0.83393127,  0.83393127]], dtype=float32)
tf_d_MEX(x).eval()
Out[11]:
array([[ 0.0850958 ,  0.19909413,  0.46581003,  0.07051659],
       [ 0.0850958 ,  0.19909413,  0.46581003,  0.07051659]], dtype=float32)

Body:
My bad, I just found the mistake.

Its here:

def MEXgrad(op, grad):
    x = op.inputs[0]
    # x = op

    n_gr = tf_d_MEX(x)
    return n_gr

I wonder if there is a typo here, where this mistake is also there.


问:
calc() function for element above desired element
I have navbar with x-height and y-padding.

Now I would like to calculate how much the main div must have, to fill the whole window.

Is it possible to this in a way like this...

.something {height: calc(100vh - .navbar(height))}...

答:
Sure. Say 35 is the sum of height and padding (top PLUS bottom) of your navbar, then your rule would be

```<code>.yourdiv {height: calc(100vh - 35px)}
</code>```

But you can't use JS in there, if that is the question. But it seems you know the height and padding of your navbar ("x-height and y-padding"), so this would be the way to go.

Body:
Sure. Say 35 is the sum of height and padding (top PLUS bottom) of your navbar, then your rule would be

.yourdiv {height: calc(100vh - 35px)}

But you can't use JS in there, if that is the question. But it seems you know the height and padding of your navbar ("x-height and y-padding"), so this would be the way to go.


问:
How to calculate difference between tables in MySQL?
What is a good way to calculate difference (in a sense what should be added and deleted from one table to get another) between tables in MySQL?</p>

答:
You can also use a left outer join (the first tells you where a row exists in table a and not b, the second vice-versa):</p>

```<code>SELECT a.id FROM a LEFT JOIN b ON a.id = b.id WHERE b.id IS NULL
SELECT b.id FROM b LEFT JOIN a ON b.id = a.id WHERE a.id IS NULL
</code>```

OwnerDisplayName: Vadim

Body:
You can also use a left outer join (the first tells you where a row exists in table a and not b, the second vice-versa):

SELECT a.id FROM a LEFT JOIN b ON a.id = b.id WHERE b.id IS NULL
SELECT b.id FROM b LEFT JOIN a ON b.id = a.id WHERE a.id IS NULL

OwnerDisplayName: BrynJ


问:
Pass parameter from one Powershell function to another
I’m new to powershell and development in general.  I’m trying to write a script that will email a contact once a file exceeds a certain size.  I have two individual functions both working separately (one to check the file size and one to generate a file for sendmail to use) but I can’t get them to interact.

I want to execute the function CheckSize and if the variable $ExceedsSize gets set to 1 then call function SendMail otherwise the script should finish with no other action.

I’ve searched through the forums but couldn’t find anything to apply to what I’m doing.

```<code>   ##Check file to see if it is over a particular size and then send email once threshold is reached.

param(
    [string]$SiteName = "TestSite",                                                 #Name of Site (No Spaces)
    [string]$Path = "\\NetworkPath\Directory",                                      #Path of directory to check
    [int]$FileSizeThreshold = 10,                                                   #Size in MB that will trigger a notification email
    [string]$Contacts = "MyEmail@email.com"
    )

CLS

##Creates variable $ExceedsSize based on newest file in folder.
Function CheckSize {
IF ((GCI $Path -Filter *.txt | Sort LastWriteTime -Descending | Select-Object -first 1 | Measure-Object -property Length -sum).sum / 1000000 -gt $FileSizeThreshold) {$ExceedsSize = 1}
ELSE {$ExceedsSize = 0}

Write-Host $ExceedsSize
}

Function SendMail {
    Param([string]$Template, [string]$Contacts, [string]$WarnTime)

    $EmailLocation = "\\NetworkPath\Scripts\File_$SiteName.txt"

    #Will Generate email from params
        New-Item $EmailLocation -type file -force -value "From: JMSIssue@emails.com`r
To: $Contacts`r
Subject: $SiteName file has exceeded the maximum file size threshold of $FileSizeThreshold MB`r`n"

    #Send Email
    #CMD /C "$SendMail\sendmail.exe -t < $EmailLocation"

    }
</code>```

答:
Add this before or after your Write-Host $ExceedsSize:

```<code>return $ExceedsSize
</code>```

Add this to the bottom:

```<code>$var = CheckSize

if ($var -eq 1){
    SendMail
}
</code>```

Explanation

You have two functions, but don't actually run them. The part at the bottom does that.

Your CheckSize function does not return the $ExceedsSize for the rest of the function; by default it remains within the scope of the function. return x means the variable is passed back to the main script. $var = means it is assigned ot that variable.

Body:
I’m new to powershell and development in general.  I’m trying to write a script that will email a contact once a file exceeds a certain size.  I have two individual functions both working separately (one to check the file size and one to generate a file for sendmail to use) but I can’t get them to interact.

I want to execute the function CheckSize and if the variable $ExceedsSize gets set to 1 then call function SendMail otherwise the script should finish with no other action.

I’ve searched through the forums but couldn’t find anything to apply to what I’m doing.

   ##Check file to see if it is over a particular size and then send email once threshold is reached.

param(
    [string]$SiteName = "TestSite",                                                 #Name of Site (No Spaces)
    [string]$Path = "\\NetworkPath\Directory",                                      #Path of directory to check
    [int]$FileSizeThreshold = 10,                                                   #Size in MB that will trigger a notification email
    [string]$Contacts = "MyEmail@email.com"
    )

CLS

##Creates variable $ExceedsSize based on newest file in folder.
Function CheckSize {
IF ((GCI $Path -Filter *.txt | Sort LastWriteTime -Descending | Select-Object -first 1 | Measure-Object -property Length -sum).sum / 1000000 -gt $FileSizeThreshold) {$ExceedsSize = 1}
ELSE {$ExceedsSize = 0}

Write-Host $ExceedsSize
}

Function SendMail {
    Param([string]$Template, [string]$Contacts, [string]$WarnTime)

    $EmailLocation = "\\NetworkPath\Scripts\File_$SiteName.txt"

    #Will Generate email from params
        New-Item $EmailLocation -type file -force -value "From: JMSIssue@emails.com`r
To: $Contacts`r
Subject: $SiteName file has exceeded the maximum file size threshold of $FileSizeThreshold MB`r`n"

    #Send Email
    #CMD /C "$SendMail\sendmail.exe -t < $EmailLocation"

    }

Body:
Add this before or after your Write-Host $ExceedsSize:

return $ExceedsSize

Add this to the bottom:

$var = CheckSize

if ($var -eq 1){
    SendMail
}

Explanation

You have two functions, but don't actually run them. The part at the bottom does that.

Your CheckSize function does not return the $ExceedsSize for the rest of the function; by default it remains within the scope of the function. return x means the variable is passed back to the main script. $var = means it is assigned ot that variable.


问:
Preventing inputs with errors re-focusing when running parsley validate
This is a strange question, I know. I am working on a rather large form that uses parsley groups for validation. It's possible to be within one group, and skip to another. When a user skips, we validate the previous group. We want to run the validation, but be don't want parsley to focus on any of the fields with errors. Showing the errors is fine. So I am wondering if it is possible to do this.</p>

答: Yes. Simply set the focus option to 'none'.