Automattic / knox

S3 Lib
MIT License
1.74k stars 285 forks source link

mime dependency breaking changes #326

Open valtlfelipe opened 7 years ago

valtlfelipe commented 7 years ago

node-mime has released a new version, which requires node>=6. And in package.json of knox requires mim in any version "mime": "*",.

My enviorment uses node 4, and this just broke my application.

Please merge https://github.com/Automattic/knox/pull/325.

See the stack trace.

/home/ubuntu/newfleet/app/node_modules/knox/node_modules/mime/Mime.js:5
class Mime {
^^^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/ubuntu/newfleet/app/node_modules/knox/node_modules/mime/index.js:1:76)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/ubuntu/newfleet/app/node_modules/knox/lib/client.js:20:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/ubuntu/newfleet/app/node_modules/knox/lib/index.js:13:28)
acarl005 commented 7 years ago

Similar problem. We use Node 8 but instead we get a runtime error.

ERROR TypeError: mime.lookup is not a function
     at /app/node_modules/knox/lib/client.js:363:28
     at FSReqWrap.oncomplete (fs.js:153:5)
tmoreno commented 7 years ago

I have the same problem that @valtlfelipe

PyroSA commented 7 years ago

Same issue. Old 0.12.7 server got re-initialised this morning.

PyroSA commented 7 years ago

Thanks @valtlfelipe & @neebz You can temporarily use their fixed version of 0.9.2 by using: "knox": "git://github.com/caremerge/knox.git#b1e031c209b3c17cab622a458e87728c1ee88cbd", In your package.json

dwjft commented 7 years ago

It seems this package is no longer maintained.

I have created a clone with the fix here: https://www.npmjs.com/package/knox-s3

No other changes other than pinning the mime version.

manuelxaguilar commented 6 years ago

So there's no chance of getting this fixed? I'm not using Knox directly, I'm actually using Keystone, which has Knox as a dependency itself, so I keep getting this mime.lookup error. Any suggestions if this won't get fixed?

valtlfelipe commented 6 years ago

@manuelxaguilar You will have to open an issue at Keystone, so they can change the konx dependency to use @dwjft fork for example :disappointed:

sedge commented 6 years ago

@manuelxaguilar @valtlfelipe You can also investigate npm shrinkwrap to prevent this sort of thing in the future.

manuelxaguilar commented 6 years ago

@valtlfelipe Yeah, I brought it up but they seem to take forever to reply... We'll see I guess.

@sedge I'm using Yarn on my project, which I believe doesn't work well with npm-shrinkwrap. I actually used resolutions to determine which version of Knox to use (I used @PyroSA fork) and it worked well on development, however it failed when deploying to Heroku because it wasn't recognizing git as a valid protocol. :/

madsleejensen commented 6 years ago

If you use yarn you can get around this issue by using https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

// package.json { .... "resolutions": { "keystone/knox/mime": "1.4.0" } }

jashmenn commented 5 years ago

Thanks @madsleejensen - that worked for me, though I was using knox via the s3-sync package, so my `"resolutions" looked like this:

    "resolutions": { "s3-sync/knox/mime": "1.4.0" } 

The key idea being, one needs to specify the path to mime via the packages they're using. (You can run yarn why mime to find yours.