I have a Swagger NodeJS project which was created using Swagger
Swagger uses swagger-connect 0.1.0 out of the box but I've now upgraded to swagger-connect 0.7.0 using the manual instructions which included adding the following to config/default.yml:
_swagger_params_parser:                    # <= Add this definition
  name: swagger_params_parser
  jsonOptions: {}
  urlencodedOptions:
    extended: false
  multerOptions:
    inMemory: true
  textOptions:
    type: "*/*"
and under section 'swagger_controllers:' I've added :
 - swagger_params_parser 
This works gloriously on my local machine but when I push to the server it throws the error:
Error initializing middleware
May 22 13:25:27 myserver "myapp": Error: Cannot find module '/var/www/myapp/node_modules/swagger-connect/node_modules/swagger-node-runner/node_modules/bagpipes/lib/fittings/swagger_params_parser'
I'm starting the server via:
node app.js
So it looks like a potential dependency bleed on my local machine but I've destroyed (rm -Rf) 'node_modules' and re-run npm install and it still works fine on my local machine but breaks on the server.
Any ideas why swagger-params-parser is missing?
Also, another weird thing is that swagger-params-parser doesn't exist locally in directory '/var/www/myapp/node_modules/swagger-connect/node_modules/swagger-node-runner/node_modules/bagpipes/lib/fittings/swagger_params_parser' and yet locally it works!?
 
                        
The issue turned out to be a stray
node_modulesdirectory on the server (we normally usenode_modules_production).Two things I've learned from this:
1.)
node_modulesis used instead ofnode_module_productionif it exists. My RPM was not overwriting the directory and hence left an old copy ofnode_moduleswhich was incorrectly packaged up at some point. The swagger app was loading modules fromnode_modulesand notnode_modules_production2.) swagger_params_parser is indeed missing, even on the working version of the code so it looks like this error:
is misleading, as that module is never present, at least in version 0.7.0 of
swagger-connect