modernizr-neue icon indicating copy to clipboard operation
modernizr-neue copied to clipboard

lodash is not defined on pre-render

Open joecritch opened this issue 9 years ago • 10 comments

I'm getting the bellow error when React.renderToString is called on the DownloadUI, through the npm run develop process

I believe this may have been mentioned before, but this only happened for me after I removed and reinstalled node_modules. Can anyone replicate?

/Users/joecritchley/Sites/modernizr-neue/frontend/js/download/LeftColumn.js:65
    options = _.map(options, function(option) {
              ^

ReferenceError: _ is not defined
    at React.createClass.render (/Users/joecritchley/Sites/modernizr-neue/frontend/js/download/LeftColumn.js:65:15)
    at ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactCompositeComponent.js:789:34)
    at ReactCompositeComponentMixin._renderValidatedComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactCompositeComponent.js:816:14)
    at wrapper [as _renderValidatedComponent] (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactPerf.js:70:21)
    at ReactCompositeComponentMixin.mountComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactCompositeComponent.js:237:30)
    at wrapper [as mountComponent] (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactPerf.js:70:21)
    at Object.ReactReconciler.mountComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactReconciler.js:38:35)
    at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactMultiChild.js:192:44)
    at ReactDOMComponent.Mixin._createContentMarkup (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactDOMComponent.js:289:32)
    at ReactDOMComponent.Mixin.mountComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactDOMComponent.js:199:12)

joecritch avatar Jan 28 '16 13:01 joecritch

Did you pull down master? This broke and was fixed last week

On Jan 28, 2016, at 5:52 AM, Joe Critchley [email protected] wrote:

I'm getting the bellow error when React.renderToString is called on the DownloadUI.

I believe this may have been mentioned before, but this only happened for me after I removed and reinstalled node_modules. Can anyone replicate?

/Users/joecritchley/Sites/modernizr-neue/frontend/js/download/LeftColumn.js:65 options = _.map(options, function(option) { ^

ReferenceError: _ is not defined at React.createClass.render (/Users/joecritchley/Sites/modernizr-neue/frontend/js/download/LeftColumn.js:65:15) at ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactCompositeComponent.js:789:34) at ReactCompositeComponentMixin._renderValidatedComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactCompositeComponent.js:816:14) at wrapper as _renderValidatedComponent at ReactCompositeComponentMixin.mountComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactCompositeComponent.js:237:30) at wrapper as mountComponent at Object.ReactReconciler.mountComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactReconciler.js:38:35) at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactMultiChild.js:192:44) at ReactDOMComponent.Mixin._createContentMarkup (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactDOMComponent.js:289:32) at ReactDOMComponent.Mixin.mountComponent (/Users/joecritchley/Sites/modernizr-neue/node_modules/react/lib/ReactDOMComponent.js:199:12) — Reply to this email directly or view it on GitHub.

patrickkettner avatar Jan 28 '16 17:01 patrickkettner

@patrickkettner I hadn't pulled (oops!), but still getting the same issue. Steps to reproduce:

  1. git fetch upstream
  2. git checkout master
  3. git merge upstream/master
  4. rm -rf node_modules
  5. npm i
  6. npm run develop

(Also double-checked this by cloning the main repo directly and running the last two steps.)

joecritch avatar Jan 29 '16 15:01 joecritch

whoop, just realized I didn't push my changes :(

rebasing off of master, and will push up shortly

patrickkettner avatar Jan 29 '16 22:01 patrickkettner

@patrickkettner Ah I'm now getting Cannot find module 'lodash'. I've tried creating an browserify alias, but no luck. Can you replicate with fresh node_modules?

joecritch avatar Feb 01 '16 20:02 joecritch

are you on npm < 3?

On Mon, Feb 1, 2016 at 12:36 PM, Joe Critchley [email protected] wrote:

Reopened #72 https://github.com/Modernizr/modernizr-neue/issues/72.

— Reply to this email directly or view it on GitHub https://github.com/Modernizr/modernizr-neue/issues/72#event-534788547.

patrick

patrickkettner avatar Feb 01 '16 23:02 patrickkettner

Yep, 2.14.7 Edit: @patrickkettner So npm2 doesn't pre-render for me. npm3 does pre-render, but then complains lodash doesn't exist on runtime. :(

Edit 2: npm run deploy works fine, but npm run develop still has the issue with npm3 whereby require('lodash') returns a blank Object. (It seems that lodash module is defined with a service worker, if I'm assuming correctly, so tried clearing the service worker cache, but no luck there.) Any other ideas?

joecritch avatar Feb 02 '16 14:02 joecritch

@patrickkettner I'm getting the same error where lodash cannot be found on download/downloader.js:939 resulting in _.map is not a function

npm_lodash_empty

Edit: this is happening when running npm run develop

jstewsy avatar Feb 24 '16 21:02 jstewsy

nothing has changed, so the error still exists. you can get around it locally by running npm install lodash

On Wed, Feb 24, 2016 at 1:45 PM, Jordan Stewart [email protected] wrote:

@patrickkettner https://github.com/patrickkettner I'm getting the same error where lodash cannot be found on download/downloader.js:939 resulting in _.map is not a function

[image: npm_lodash_empty] https://cloud.githubusercontent.com/assets/5373779/13302070/f8a83470-db15-11e5-994c-f8b2dd5de161.png

— Reply to this email directly or view it on GitHub https://github.com/Modernizr/modernizr-neue/issues/72#issuecomment-188465937 .

patrick

patrickkettner avatar Feb 25 '16 01:02 patrickkettner

@patrickkettner I'm not sure if that resolves the issue, still seeing _ showing up as an empty Object.

either way the server is failing to initialize sometimes with this error

/Users/jstewart/src/modernizr/frontend/js/download/LeftColumn.js:79
        toggleClassPrefix: this.toggleClassPrefix
                               ^

TypeError: Cannot read property 'toggleClassPrefix' of undefined
    at /Users/jstewart/src/modernizr/frontend/js/download/LeftColumn.js:79:32

jstewsy avatar Feb 26 '16 01:02 jstewsy

@patrickkettner I also have troubles setting the page up to fix a few things (node8 npm5.6). Bitrot? Or can you still setup and deploy it?

rejas avatar May 25 '18 12:05 rejas