Hello!
I just wanted to test production config of my application. I set NODE_ENV to "production" and called node server/server.js and it returned me this:
/vagrant/node_modules/loopback-boot/lib/config-loader.js:239
throw new Error('Cannot apply ' + fileName + ': ' + err);
^
Error: Cannot apply /vagrant/server/component-config.production.json: Cannot merge values of incompatible types for the optionloopback-component-explorer.
at mergeComponentConfig (/vagrant/node_modules/loopback-boot/lib/config-loader.js:239:11)
at mergeConfigurations (/vagrant/node_modules/loopback-boot/lib/config-loader.js:138:5)
at loadNamed (/vagrant/node_modules/loopback-boot/lib/config-loader.js:76:16)
at Object.ConfigLoader.loadComponents (/vagrant/node_modules/loopback-boot/lib/config-loader.js:56:10)
at compile (/vagrant/node_modules/loopback-boot/lib/compiler.js:60:20)
at bootLoopBackApp (/vagrant/node_modules/loopback-boot/index.js:139:22)
at Object.(/vagrant/server/server.js:21:1)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
here is my component-config.production.json
{
"loopback-component-explorer": false
}
and middleware.production.json
{
"final:after": {
"loopback#errorHandler": {
"params": {
"includeStack": false
}
}
}
}
Here is my slc -v
slc -v
strongloop v5.0.1 (node v4.2.1)
โโโ [email protected] (d95b140)
โโโ [email protected] (d008a3e)
โโโ [email protected] (be6180a)
โโโ [email protected] (62e539b)
โโโ [email protected] (b96f806)
โโโ [email protected] (f46e58f)
โโโ [email protected] (1327018)
โโโฌ [email protected] (46b06b4)
โ โโโ [email protected] (4ea7ee9)
โโโ [email protected] (a374136)
โโโ [email protected]
โโโ [email protected]
And i failed to understand why it crushes and why it shows stacktrace on it's crush
Could you help, please?
UPD: same problem with node v4.0.0
I suppose in your component-config.json, looks like :
{
"loopback-component-explorer": {
"mountPath": 'xxxx'
}
}
The problem here is that when you set NODE_ENV to production, the merge utility of loopback will try to merge a boolean (in this case , false in your component-config.production.json) with Object and it fails to merge them.
The simplest way to disable explorer is to remove explorer.js and the component-config.{}.json file entirely in your production server. That is what I do.
Another workaround:
{
"loopback-component-explorer": false
}
{
"loopback-component-explorer": {
"mountPath": "/explorer"
}
}
{
}
Hey @echmykhun can you provide a sample repo for me to reproduce the issue, please? https://github.com/strongloop/loopback/wiki/Reporting-issues#bug-report
I'm having the same problem. While @pavlin99th's solution provides a temporary fix (thanks for that!), I think the right solution would be to completely replace the config object if the value in the production file is a boolean with the value false as in:
{
"loopback-component-explorer": false
}
@mastertinner's idea is a good one!
@mastertinner agreed +1
+1
@echmykhun why is this being closed? How @mastertinner describes it, is how it should actually work in general when merging configurations.
@echmykhun so you don't think this is a problem that loopback need to solve?
same problem here, no need for a repo to reproduce the issue, just follow the documentation: https://docs.strongloop.com/display/public/LB/Environment-specific+configuration#Environment-specificconfiguration-DisablingAPIExplorer
@echmykhun Should re-open and accept PR.
Most helpful comment
same problem here, no need for a repo to reproduce the issue, just follow the documentation: https://docs.strongloop.com/display/public/LB/Environment-specific+configuration#Environment-specificconfiguration-DisablingAPIExplorer