Modernizr: Module not found: Error: Cannot resolve module 'ModernizrProto'

Created on 16 Jun 2016  Â·  11Comments  Â·  Source: Modernizr/Modernizr

Hi,

I'm calling modenizr via webpack and I keep getting this error

ERROR in ./~/modernizr/src/modernizr.js
Module not found: Error: Cannot resolve module 'ModernizrProto' in (path to modernizr)

I can see that ModernizrProto.js is there.

Can anyone help?

Most helpful comment

@buley I'd suggest using the npm builder we offer at modernizr.com

npm install https://modernizr.com/download?ambientlight-batteryapi-webp-setclasses --save

All 11 comments

hey @ashbryant what is it you are calling? your build? the moderizr module?

ping @ashbryant

@patrickkettner Sorry, I've been away.

It's in node_modules/modernizr/src/modernizr.js

no worries!

So that is actually probably not what you want. That is the base file that the modular build is built around. Have you created the build of modernizr that you want?

I ran into this issue as well. The reason I'm using the basefile is that the uglification and optimization processes seem to prefer raw base files. I was hoping to build from npm source in a repeatable way. Now planning to do a manual build instead.

@buley I'd suggest using the npm builder we offer at modernizr.com

npm install https://modernizr.com/download?ambientlight-batteryapi-webp-setclasses --save

Thanks for the link @patrickhlauke. Although your method works, I'm wondering if you can make the npm verion of the library usable as well. The problem with the non-npm package source is that the app now depends on the availability of your website and the network. Installing modernizr in a CI scripts feels potentially slower and riskier because of talking to an additional website.

How feasible would it be to fix the npm package for webpack? I guess everyone will be happy to import Modernizr from 'modernizer/some/extra/path' or import Modernizr from 'modernizer-webpack' if needed.

i'm assuming you meant @patrickkettner and not me ... confused me there for a second

Ah sorry!

2 @patrickkettner: Just tried your method and got this in package.json / package-lock.json:

    "Modernizr": "https://modernizr.com/download?ambientlight-batteryapi-webp-setclasses",
    "Modernizr": {
      "version": "https://modernizr.com/download?ambientlight-batteryapi-webp-setclasses",
      "integrity": "sha1-vQBWX2FvDUyoLiZ0fGK2P1n6Rqc="
    },



md5-7713a92f1931d1db21003e8a2152df0f



npm ERR! code EINTEGRITY
npm ERR! sha1-vQBWX2FvDUyoLiZ0fGK2P1n6Rqc= integrity checksum failed when using sha1: wanted sha1-vQBWX2FvDUyoLiZ0fGK2P1n6Rqc= but got sha1-33GogvH/vyMjWkqrGcO8EGvrDps=. (30208 bytes)

i'll probably move Modernizr into src for now – fetching npm packages not from an npm registry feels like a bad idea.

@kachkaev all that is happening is your lock file is being invalidated because of package changes. thats the point of the lock file. You just need to delete the lock file to upgrade your modernizr package.

It be awesome to programmatically use Modernize with ease -- I don't want it on the window, I don't want it to touch the document.documentElement.

I got it to work with mapping all the named modules and trying to figure out how to implement this dynamically in the future.

My use case:
Attempting to make all my Component classes standalone and able to add their own specific detects per Components' use-cases. Encapsulate and modularize all the things!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peterwilsoncc picture peterwilsoncc  Â·  9Comments

lovetrivedi picture lovetrivedi  Â·  4Comments

MariuszGorzoch picture MariuszGorzoch  Â·  9Comments

aaarichter picture aaarichter  Â·  6Comments

claudchan picture claudchan  Â·  7Comments