Giter VIP home page Giter VIP logo

Comments (23)

s-kalaus avatar s-kalaus commented on May 23, 2024 73

Problem is that in Node 12 Module Not Found error differs from Node 10. bagpipes relies on error message text. This can tepmorary be fixed in this file: node_modules/bagpipes/lib/fittingTypes/user.js file:
var split = err.message.split(path.sep);
should be
var split = err.message.split('\n')[0].split(path.sep);

from swagger-node.

gohmc avatar gohmc commented on May 23, 2024 63

Try this, tested on node version to date (12.13.1):

  1. Update your swagger-express-mw:

"swagger-express-mw": "^0.7.0"

  1. Add swagger_params_parser to swagger_controllers at config/default.yaml
    ...

pipe for all swagger-node controllers

swagger_controllers:
  - onError: json_error_handler
  - cors
  - swagger_params_parser
  ...
  1. Run npm install

  2. Run swagger project start

I wish swagger-node will receive more timely update.

from swagger-node.

deventorum avatar deventorum commented on May 23, 2024 24

This is probably because you are running node v12.2.0! Try to downgrade your node to version 10, version 12 is not stable.

from swagger-node.

smeckman avatar smeckman commented on May 23, 2024 2

@gohmc - Thank you, your solution works splendidly with v12.16.1 and requires minimal configuration without touching the code.

from swagger-node.

pz2147 avatar pz2147 commented on May 23, 2024 1

I know how to fixed this issue.

Copy some files
from project/node_modules/swagger-node-runner/fittings to project/api/fittings/swagger_router,
from project/node_modules/bagpipes/lib/fittings to project/api/fittings/swagger_router

Finally, start is OK.

I think I have make a wrong path with module.

from swagger-node.

balain avatar balain commented on May 23, 2024 1

Try this, tested on node version to date (12.13.1):

1. Update your swagger-express-mw:

"swagger-express-mw": "^0.7.0"

1. Add swagger_params_parser to swagger_controllers at config/default.yaml
   ...

pipe for all swagger-node controllers

swagger_controllers:
  - onError: json_error_handler
  - cors
  - swagger_params_parser
  ...
1. Run npm install

2. Run swagger project start

I wish swagger-node will receive more timely update.

Thanks for the fix @gohmc.

Note: this fix also works for me with node v15.1.0

from swagger-node.

adarshsingh6162 avatar adarshsingh6162 commented on May 23, 2024 1

Try this, tested on node version to date (12.13.1):

  1. Update your swagger-express-mw:

"swagger-express-mw": "^0.7.0"

  1. Add swagger_params_parser to swagger_controllers at config/default.yaml
    ...

pipe for all swagger-node controllers

swagger_controllers:
  - onError: json_error_handler
  - cors
  - swagger_params_parser
  ...
  1. Run npm install
  2. Run swagger project start

I wish swagger-node will receive more timely update.

This fixes the error but routes are not working properly.
For eg. 1) - GET /path/{id}
2) - POST /path/xyz

while making call to POST /path/xyz, it's throwing error method POST is not defined for /path/{id}
It's treating xyz as some id

from swagger-node.

mozhaev94 avatar mozhaev94 commented on May 23, 2024 1
  • onError: json_error_handler
    • cors
    • swagger_params_parser

Thank you! It`s works for me

from swagger-node.

ranrao avatar ranrao commented on May 23, 2024

Is this the best approach to fix the issue? This seems like a new problem with Swagger. Please help with the right approach. Thanks.

from swagger-node.

racingfever avatar racingfever commented on May 23, 2024

I also had same problems. Tried the file copying from fittings-directory. This didn't work for me.
I downgraded node to 10.16.0 (and npm 6.9.0) and all was solved....

from swagger-node.

binhapp avatar binhapp commented on May 23, 2024

@deventorum Node v10.16.0 is work for me. Thank you!

from swagger-node.

crutlandTAG avatar crutlandTAG commented on May 23, 2024

I have the exact same issue as the OP. Node v12 is becoming LTS in one month; I'd generally assume I should be able to follow the instructions in the README and have a working 'getting started' project. This doesn't appear to be the case at the moment.

from swagger-node.

rajeshpudota avatar rajeshpudota commented on May 23, 2024

I have the exact same issue too. I was trying to upgrade to node v12.

Error initializing middleware
Error: Cannot find module '/Users/nodejs/services/account/api/fittings/swagger_router'
Require stack:

  • /Users/nodejs/services/account/node_modules/bagpipes/lib/fittingTypes/user.js
  • /Users/nodejs/services/account/node_modules/bagpipes/lib/bagpipes.js
  • /Users/nodejs/services/account/node_modules/bagpipes/lib/index.js
  • /Users/nodejs/services/account/node_modules/swagger-node-runner/index.js
  • /Users/nodejs/services/account/node_modules/swagger-express-mw/lib/index.js
  • /Users/nodejs/services/account/node_modules/cm-util/app-start.js
  • /Users/nodejs/services/account/node_modules/cm-util/index.js
  • /Users/nodejs/services/account/app.js

from swagger-node.

shiranyo avatar shiranyo commented on May 23, 2024

Happens to me as well on node 12

from swagger-node.

Ethns avatar Ethns commented on May 23, 2024

Same issue
env: node 12.13.1 npm 6.12.1

from swagger-node.

taitelman avatar taitelman commented on May 23, 2024

I also had to move to node 12 and since I felt this lib is no longer maintained nor supported I decided to shift to swagger-ui-express . the above solution could have saved me serveral hours of debugging.

from swagger-node.

sonywibisono avatar sonywibisono commented on May 23, 2024

try to install swagger-router with command
$npm install --save swagger-router

it's work for me

from swagger-node.

amrendraw3 avatar amrendraw3 commented on May 23, 2024

This is probably because you are running node v12.2.0! Try to downgrade your node to version 10, version 12 is not stable.

This worked for me as well, downgraded to v10.15.0.

from swagger-node.

cp99says avatar cp99says commented on May 23, 2024

Try this, tested on node version to date (12.13.1):

  1. Update your swagger-express-mw:

"swagger-express-mw": "^0.7.0"

  1. Add swagger_params_parser to swagger_controllers at config/default.yaml
    ...

pipe for all swagger-node controllers

swagger_controllers:
  - onError: json_error_handler
  - cors
  - swagger_params_parser
  ...
  1. Run npm install
  2. Run swagger project start

I wish swagger-node will receive more timely update.

I did the same but the issue wasnt resolved, its showing this error
`Error initializing middleware
Error: Cannot find module 'D:\swagggggger\hello\api\fittings\swagger_router'
Require stack:

  • D:\swagggggger\hello\node_modules\bagpipes\lib\fittingTypes\user.js
  • D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js
  • D:\swagggggger\hello\node_modules\bagpipes\lib\index.js
  • D:\swagggggger\hello\node_modules\swagger-node-runner\index.js
  • D:\swagggggger\hello\node_modules\swagger-express-mw\lib\index.js
  • D:\swagggggger\hello\app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1080:15)
    at Function.Module._load (internal/modules/cjs/loader.js:923:27)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at createFitting (D:\swagggggger\hello\node_modules\bagpipes\lib\fittingTypes\user.js:18:20)
    at Bagpipes.newFitting (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:158:17)
    at Bagpipes.createFitting (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:147:22)
    at Bagpipes.createPipe (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:111:19)
    at Bagpipes.getPipe (D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:50:38)
    at D:\swagggggger\hello\node_modules\bagpipes\lib\bagpipes.js:34:10`

how should I sort it out? @gohmc

from swagger-node.

JonanOribe avatar JonanOribe commented on May 23, 2024

I solved the problem downgrading my Node version to 10.23.0

from swagger-node.

SteversIO avatar SteversIO commented on May 23, 2024

Wow this project is absolutely unmaintained. I experienced the same issue as all of the above.

Even the code that is auto-generated for the hello world controller is stale.

req.param('name') is the valid way to pull parameters from the request object now.

Now req.swagger.params.name.value

from swagger-node.

sscots avatar sscots commented on May 23, 2024

I think I've figured out a way around this error with the following changes to the fittingsDir:

fittingsDirs: [ node_modules/swagger-node-runner/fittings ]

Then I had to remove this line under "swagger_controllers" to get it work, or else I get an error complaining about "onError" not being a fitting.

- onError: json_error_handler

I don't think, in my case, that I really need the json_error_handler. But tbh, I'm not 100% sure what it does. Does anyone know?

from swagger-node.

CiriloGaspar avatar CiriloGaspar commented on May 23, 2024

Try this, tested on node version to date (12.13.1):

  1. Update your swagger-express-mw:

"swagger-express-mw": "^0.7.0"

  1. Add swagger_params_parser to swagger_controllers at config/default.yaml
    ...

pipe for all swagger-node controllers

swagger_controllers:
  - onError: json_error_handler
  - cors
  - swagger_params_parser
  ...
  1. Run npm install
  2. Run swagger project start

I wish swagger-node will receive more timely update.

Thanks alot, it's works for me.

I had the same issue with env:

Node -v: 16.16.0

npm -v: 8.11.0

from swagger-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.