strues / react-universal-boiler

A bold way to begin your next great universal React application. Uses Webpack 3, React 16, Redux, and more for a great developer experience.
MIT License
65 stars 11 forks source link

Build Fails after adding few client libs [material-ui, redux-form, wallop, react-tap-event-plugin] #8

Closed hirenchauhan2 closed 8 years ago

hirenchauhan2 commented 8 years ago

I get this error when I run npm run build

E:\ReactJS\react-universal-boiler>npm run build

> boldr-universal-react@0.1.1 build E:\ReactJS\react-universal-boiler
> npm-run-all -s clean build:server build:client

> boldr-universal-react@0.1.1 clean E:\ReactJS\react-universal-boiler
> rimraf static/assets && rimraf static/server.js && rimraf static/server.js.map && rimraf static/webpack-assets.json && rimraf static/webpack-stats.json

> boldr-universal-react@0.1.1 build:server E:\ReactJS\react-universal-boiler
> better-npm-run build:server

running better-npm-run in E:\ReactJS\react-universal-boiler
Executing script: build:server

to be executed: "webpack --config tools/webpack/webpack.config.node.js"
E:\ReactJS\react-universal-boiler\node_modules\loader-runner\lib\LoaderRunner.js:128
                if(isError) throw e;
                            ^

TypeError: Cannot read property 'replace' of undefined
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\NormalModuleFactory.js:89:26
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\NormalModuleFactory.js:39:4
    at handleExternal (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:25:32)
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:81:24
    at next (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:45:41)
    at handleExternals (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:59:7)
    at ExternalModuleFactoryPlugin.<anonymous> (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:79:5)
    at handleExternal (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:25:32)
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:81:24
    at next (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:45:41)
    at handleExternals (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:59:7)
    at ExternalModuleFactoryPlugin.<anonymous> (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\ExternalModuleFactoryPlugin.js:79:5)
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\NormalModuleFactory.js:207:3
    at E:\ReactJS\react-universal-boiler\node_modules\tapable\lib\Tapable.js:131:11
    at NormalModuleFactory.<anonymous> (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\NormalModuleReplacementPlugin.js:26:11)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (E:\ReactJS\react-universal-boiler\node_modules\tapable\lib\Tapable.js:135:13)
    at NormalModuleFactory.create (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\NormalModuleFactory.js:191:8)
    at async.forEach._this (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\Compilation.js:211:11)
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\node_modules\async\lib\async.js:181:20
    at Object.async.forEachOf.async.eachOf (E:\ReactJS\react-universal-boiler\node_modules\webpack\node_modules\async\lib\async.js:233:13)
    at Object.async.forEach.async.each (E:\ReactJS\react-universal-boiler\node_modules\webpack\node_modules\async\lib\async.js:209:22)
    at Compilation.addModuleDependencies (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\Compilation.js:192:8)
    at Compilation.processModuleDependencies (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\Compilation.js:177:7)
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\Compilation.js:317:12
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\Compilation.js:124:4
    at Array.forEach (native)
    at callback (E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\Compilation.js:123:12)
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\Compilation.js:147:10
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\NormalModule.js:209:10
    at E:\ReactJS\react-universal-boiler\node_modules\webpack\lib\NormalModule.js:164:10

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "build:server"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! boldr-universal-react@0.1.1 build:server: `better-npm-run build:server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the boldr-universal-react@0.1.1 build:server script 'better-npm-run build:server'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the boldr-universal-react package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     better-npm-run build:server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs boldr-universal-react
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls boldr-universal-react
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\ReactJS\react-universal-boiler\npm-debug.log
ERROR: "build:server" exited with 1.

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! boldr-universal-react@0.1.1 build: `npm-run-all -s clean build:server build:client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the boldr-universal-react@0.1.1 build script 'npm-run-all -s clean build:server build:client'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the boldr-universal-react package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm-run-all -s clean build:server build:client
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs boldr-universal-react
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls boldr-universal-react
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\ReactJS\react-universal-boiler\npm-debug.log

E:\ReactJS\react-universal-boiler>

My package.json file:

{
  "name": "boldr-universal-react",
  "version": "0.1.1",
  "description": "A bold universal React starter project.",
  "betterScripts": {
    "build:client": {
      "command": "webpack --env production --config tools/webpack/webpack.config.client.js",
      "env": {
        "DEBUG": "boldr:*",
        "NODE_ENV": "production",
        "BABEL_ENV": "production",
        "SSR_PORT": 3000
      }
    },
    "build:server": {
      "command": "webpack --config tools/webpack/webpack.config.node.js",
      "env": {
        "NODE_ENV": "production",
        "BABEL_ENV": "production",
        "SSR_PORT": 3000
      }
    },
    "dev:client": {
      "command": "node ./tools/webpack/dev.server.js",
      "env": {
        "DEBUG": "boldr:*",
        "NODE_ENV": "development",
        "BABEL_ENV": "development",
        "SSR_PORT": 3000,
        "HMR_PORT": 3001,
        "WEBPACK_DLLS": 1
      }
    },
    "dev:server": {
      "command": "node ./bin/dev.js",
      "env": {
        "DEBUG": "boldr:*",
        "NODE_ENV": "development",
        "BABEL_ENV": "development",
        "SSR_PORT": 3000,
        "HMR_PORT": 3001,
        "WEBPACK_DLLS": 1
      }
    },
    "start:prod": {
      "command": "node ./bin/run.js",
      "env": {
        "NODE_ENV": "production",
        "SSR_PORT": 3000,
        "WEBPACK_DLLS": 0
      }
    },
    "test": {
      "command": "nyc mocha --compilers js:./tools/test/mocha.js --require tools/test/clientHelper.js --require ignore-styles --opts ./tools/test/mocha.opts './src/**/*.test.js'",
      "env": {
        "BABEL_ENV": "test",
        "NODE_ENV": "test"
      }
    }
  },
  "scripts": {
    "build": "npm-run-all -s clean build:server build:client",
    "build:client": "better-npm-run build:client",
    "build:server": "better-npm-run build:server",
    "build:dlls": "webpack --verbose --colors --display-error-details --config ./tools/webpack/dll.config.js",
    "clean": "rimraf static/assets && rimraf static/server.js && rimraf static/server.js.map && rimraf static/webpack-assets.json && rimraf static/webpack-stats.json",
    "clean:server": "rimraf static/server.js && rimraf static/server.js.map",
    "coverage": "nyc report --reporter=text-lcov | coveralls",
    "dev": "npm-run-all --parallel dev:client dev:server",
    "dev:client": "better-npm-run dev:client",
    "dev:server": "better-npm-run dev:server",
    "postinstall": "npm run build:dlls",
    "start:prod": "better-npm-run start:prod",
    "test": "better-npm-run test"
  },
  "main": "index.js",
  "author": "Steven Truesdell <steven@strues.io>",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/strues/boldr-universal-react.git"
  },
  "keywords": [
    "react",
    "webpack",
    "babel",
    "universal",
    "es6",
    "es7",
    "starter",
    "javascript",
    "redux"
  ],
  "bugs": {
    "url": "https://github.com/strues/boldr-universal-react/issues"
  },
  "engines": {
    "node": "~6.x",
    "npm": "~3.x"
  },
  "homepage": "https://github.com/strues/boldr-universal-react#readme",
  "nyc": {
    "check-coverage": true,
    "lines": 65,
    "statements": 65,
    "functions": 45,
    "include": [
      "src/**/*.js"
    ],
    "exclude": [
      "src/**/*.test.js"
    ],
    "reporter": [
      "lcov",
      "text-summary"
    ],
    "require": [
      "babel-register",
      "babel-polyfill",
      "./tools/test/clientHelper.js"
    ],
    "extension": [
      ".js"
    ],
    "sourceMap": false,
    "instrument": false
  },
  "devDependencies": {
    "assets-webpack-plugin": "^3.4.0",
    "autoprefixer": "^6.5.0",
    "babel-core": "^6.17.0",
    "babel-loader": "^6.2.5",
    "babel-plugin-istanbul": "^2.0.1",
    "babel-plugin-lodash": "^3.2.9",
    "babel-plugin-module-resolver": "^2.2.0",
    "babel-polyfill": "^6.16.0",
    "babel-preset-boldr": "^1.0.2",
    "babel-register": "^6.16.3",
    "chai": "^3.5.0",
    "chai-enzyme": "^0.5.2",
    "coveralls": "^2.11.14",
    "css-loader": "^0.25.0",
    "enzyme": "^2.4.1",
    "eslint": "^3.7.0",
    "eslint-config-boldr": "^1.1.1",
    "eslint-import-resolver-babel-module": "^2.0.1",
    "eslint-loader": "^1.5.0",
    "eslint-plugin-babel": "^3.3.0",
    "eslint-plugin-import": "^2.0.0",
    "eslint-plugin-react": "^6.3.0",
    "extract-text-webpack-plugin": "^2.0.0-beta.4",
    "file-loader": "^0.9.0",
    "happypack": "^2.2.1",
    "ignore-styles": "^5.0.1",
    "jsdom": "^9.6.0",
    "json-loader": "^0.5.4",
    "lodash-webpack-plugin": "^0.10.1",
    "mocha": "^3.1.0",
    "mocha-lcov-reporter": "^1.2.0",
    "node-sass": "^3.10.1",
    "nyc": "^8.3.0",
    "postcss-loader": "^0.13.0",
    "react-hot-loader": "^3.0.0-beta.5",
    "rimraf": "^2.5.4",
    "sass-loader": "^4.0.2",
    "sinon": "^1.17.6",
    "sinon-chai": "^2.8.0",
    "style-loader": "^0.13.1",
    "url-loader": "^0.5.7",
    "webpack": "^2.1.0-beta.25",
    "webpack-dev-middleware": "^1.8.3",
    "webpack-hot-middleware": "^2.12.2",
    "webpack-node-externals": "^1.4.3"
  },
  "dependencies": {
    "async": "^2.0.1",
    "bcrypt-nodejs": "0.0.3",
    "better-npm-run": "0.0.11",
    "body-parser": "^1.15.2",
    "classnames": "^2.2.5",
    "compression": "^1.6.2",
    "connect-mongo": "^1.3.2",
    "crypto": "0.0.3",
    "debug": "^2.2.0",
    "dotenv": "^2.0.0",
    "error-handler": "^1.0.0",
    "errorhandler": "^1.4.3",
    "es6-promise": "^4.0.4",
    "express": "^4.14.0",
    "express-session": "^1.14.1",
    "express-validator": "^2.20.10",
    "lodash": "^4.16.2",
    "lusca": "^1.4.1",
    "material-ui": "^0.16.0",
    "mongoose": "^4.6.3",
    "morgan": "^1.7.0",
    "nodemailer": "^2.6.4",
    "nodemailer-mailgun-transport": "git+https://github.com/orliesaurus/nodemailer-mailgun-transport.git",
    "npm-run-all": "^3.1.0",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "react": "^15.3.2",
    "react-dom": "^15.3.2",
    "react-helmet": "^3.1.0",
    "react-redux": "^4.4.5",
    "react-router": "^2.8.1",
    "react-router-redux": "^4.0.6",
    "react-tap-event-plugin": "^1.0.0",
    "redial": "^0.5.0",
    "redux": "^3.6.0",
    "redux-form": "^6.1.0",
    "redux-thunk": "^2.1.0",
    "serialize-javascript": "^1.3.0",
    "serve-favicon": "^2.3.0",
    "source-map-support": "^0.4.3",
    "stripe": "^4.11.0",
    "superagent": "^2.3.0",
    "wallop": "^2.4.1",
    "webfontloader": "^1.6.26",
    "webpack-isomorphic-tools": "^2.5.8"
  }
}
strues commented 8 years ago

Easy fix. I just updated the repo. If you check bc09176ff9d09538ca902677df6be7454cd1a342 it shows what line needs to be modified.

Sorry about that.

hirenchauhan2 commented 8 years ago

Now getting errors for style-loader in /node_modules/style-loader/addStyles.js

isOldIE = memoize(function() {
    return false; 
    // return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase()); // error window is not defined! 
 }),
getHeadElement = memoize(function () {
    return document.head || document.getElementsByTagName("head")[0]; // error document is not defined!
}),

Also found in that same file:
````js
module.exports = function(list, options) {
    if(typeof DEBUG !== "undefined" && DEBUG) {
        if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
    }
 ......

As we know window is not available in Node globals. So how can we mimic window object in node env?

hirenchauhan2 commented 8 years ago

Now getting errors for style-loader in /node_modules/style-loader/addStyles.js

isOldIE = memoize(function() {
    return false; 
    // return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase()); // error window is not defined! 
 }),
getHeadElement = memoize(function () {
    return document.head || document.getElementsByTagName("head")[0]; // error document is not defined!
}),

Also found in that same file:

module.exports = function(list, options) {
    if(typeof DEBUG !== "undefined" && DEBUG) {
        if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
    }
 ......

As we know window is not available in Node globals. So how can we mimic window object in node env?

strues commented 8 years ago

Took me a few minutes to figure out what I think you're trying to do. Let me know if Im off.

Wallop, contains its own set of stylesheets, so when you're importing it into your application, Webpack attempts to parse the css alongside the js.

Look in the webpack.config.client.js for this section and comment out exclude: /node_modules/

{
          test: /\.css$/,
          // exclude: /node_modules/,
          loader: isDev ?
            'style!css?localIdentName=[name]__[local].[hash:base64:5]&modules&sourceMap&-minimize&importLoaders=1!postcss' :
            ExtractTextPlugin.extract({
              fallbackLoader: 'style',
              loader: 'css?modules&sourceMap&importLoaders=1!postcss'
            }),
        }

That should solve your issue since, webpack will now look in node_modules as a possible area to resolve css files from.

hirenchauhan2 commented 8 years ago

I've already copied and changed ext to .scss files and placed with my component dir. no probem with that. its still style-loader's problem.

Take a look at https://github.com/harry008/manavjyot repo

strues commented 8 years ago

I've already copied and changed ext to .scss files and placed with my component dir. no probem with that. its still style-loader's problem. Take a look at https://github.com/harry008/manavjyot repo

I pulled your repo down and played around with it for a little while. I'm somewhat puzzled. By commenting out the imported styles from Contacts and from Donation, it builds fine. Keep those two files imported and it breaks. Everywhere else that has styles imported works how they should.

hirenchauhan2 commented 8 years ago

Yeah, just don't import styles in the component. Import them in the theme/main.scss file then it works fine. Anyway I can live with this for now. By the way thanks for the support. Great work 👍 😄

strues commented 8 years ago

No problem at all. Glad I could attempt to help out. I just tried something this morning and it works; you might want to give it a shot...

Instead of naming a sass file as Home.scss try using a different word other than what the folder / component are named. I wasnt able to do import './Home.scss'; but import './style.scss'; works just fine.