Closed sdesalas closed 7 years ago
Mime version 2.0.0
onwards provides a force=true
flag to allow multiple calls to .define()
for the same mime type, which in turn stops the error from being thrown.
Fix as follows:
/**
* Define "form" mime type.
*/
mime.define({
'application/x-www-form-urlencoded': ['form', 'urlencoded', 'form-data']
}, true); // <--- add 'force=true' here
I believe this is fixed for superagent
but somehow I still get this error when using supertest
to hit my endpoints. This was ok just yesterday, then today it's not working... Can anyone help here or is this an issue for supertest
?
Based on this, https://github.com/strongloop/loopback-next/issues/6616, I updated loopback-connector-rest
from ^3 to ^4.0.1. It has the fix for mime force=true.
Superagent has recently been upgraded to use version
2.0.3
of mime.However, between version
1.4.1
and2.0.3
ofmime
an earlier warning has been upgraded to an error when defining the same mime types twice .And since many other packages and tools rely on
superagent
, the lack of pre-check before defining mime-types a second time is causing subsequentrequire("superagent")
calls from erroring out as per the example below (whenever two packages featuresuperagent
as a dependency).Use following steps to reproduce the error.
And the output: