Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Swagger ui 3.x building problem on Windows #3153

Closed
SimCordy opened this issue May 31, 2017 · 7 comments
Closed

Swagger ui 3.x building problem on Windows #3153

SimCordy opened this issue May 31, 2017 · 7 comments

Comments

@SimCordy
Copy link

SimCordy commented May 31, 2017

Hi,

I'm trying to rebuild swagger ui, because I made some changes to the swagger js library and consequently to the swagger-client index.js file, when I run the npm run buil command in the swagger ui folder, it return me errors, this is the npm log

file:0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm@3.10.10
3 info using node@v6.10.3
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle swagger-ui@3.0.8prebuild: swagger-ui@3.0.8
6 silly lifecycle swagger-ui@3.0.8
prebuild: no script for prebuild, continuing
7 info lifecycle swagger-ui@3.0.8build: swagger-ui@3.0.8
8 verbose lifecycle swagger-ui@3.0.8
build: unsafe-perm in lifecycle true
9 verbose lifecycle swagger-ui@3.0.8build: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\Sibo\Desktop\swagger-ui\swagger-ui-master\swagger-ui-master\node_modules.bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\MATLAB\R2016b\bin;C:\Program Files (x86)\Brackets\command;C:\Program Files\nodejs;C:\Users\Sibo\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\Sibo\AppData\Roaming\npm
10 verbose lifecycle swagger-ui@3.0.8
build: CWD: C:\Users\Sibo\Desktop\swagger-ui\swagger-ui-master\swagger-ui-master
11 silly lifecycle swagger-ui@3.0.8build: Args: [ '/d /s /c',
11 silly lifecycle 'npm run build-core & npm run build-bundle & npm run build-standalone' ]
12 silly lifecycle swagger-ui@3.0.8
build: Returned: code: 1 signal: null
13 info lifecycle swagger-ui@3.0.8~build: Failed to exec build script
14 verbose stack Error: swagger-ui@3.0.8 build: npm run build-core & npm run build-bundle & npm run build-standalone
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:886:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid swagger-ui@3.0.8
16 verbose cwd C:\Users\Sibo\Desktop\swagger-ui\swagger-ui-master\swagger-ui-master
17 error Windows_NT 10.0.14393
18 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "build"
19 error node v6.10.3
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error swagger-ui@3.0.8 build: npm run build-core & npm run build-bundle & npm run build-standalone
22 error Exit status 1
23 error Failed at the swagger-ui@3.0.8 build script 'npm run build-core & npm run build-bundle & npm run build-standalone'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the swagger-ui package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error npm run build-core & npm run build-bundle & npm run build-standalone
23 error You can get information on how to open an issue for this project with:
23 error npm bugs swagger-ui
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls swagger-ui
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Can you tell me please the right command to build swagger ui on windows?

I'm using windows 10 nodejs v6.10.3 and npm 3.10.10

@shockey shockey self-assigned this May 31, 2017
@shockey
Copy link
Contributor

shockey commented May 31, 2017

@SimCordy can you try using UI version 3.0.12? We solved a similar issue a few weeks ago, that was unique to 3.0.8: #3027

@SimCordy
Copy link
Author

SimCordy commented Jun 1, 2017

Thank you! The command run build with the new version works. I have only a little problem I'm using a modified version of the swagger-client, and now during the building process I get the errors:

ERROR in C:/Users/Sibo//coap/index.js
Module not found: Error: Cannot resolve module 'net' in C:\Users\Sibo\node_modules\coap
@ C:/Users/Sibo/
/coap/index.js 13:22-36

ERROR in C:/Users/Sibo//coap/lib/server.js
Module not found: Error: Cannot resolve module 'net' in C:\Users\Sibo\node_modules\coap\lib
@ C:/Users/Sibo/
/coap/lib/server.js 13:22-36

ERROR in C:/Users/Sibo//coap/lib/agent.js
Module not found: Error: Cannot resolve module 'dgram' in C:\Users\Sibo\node_modules\coap\lib
@ C:/Users/Sibo/
/coap/lib/agent.js 12:22-38

ERROR in C:/Users/Sibo//coap/lib/server.js
Module not found: Error: Cannot resolve module 'dgram' in C:\Users\Sibo\node_modules\coap\lib
@ C:/Users/Sibo/
/coap/lib/server.js 11:22-38

Do you know how I can resolve it?

@shockey
Copy link
Contributor

shockey commented Jun 1, 2017

@SimCordy, that's a very strange error trace. Can you elaborate on how you modified swagger-client?

@SimCordy
Copy link
Author

SimCordy commented Jun 1, 2017

Yes, I make some changes to the execute.js file in order to support the coap protocol by means of the node-coap module, so now in the execute source file appears the require('coap') instruction and obvious other changes.
I think that these errors are related to the node coap module, when I try to integrate it into the swgger ui.
The swagger-client alone works and build without errors, it give me errors only when I replace the swagger-client folder in the swagger ui/node_modules folder.
To solve the problem I tryed with the command:

npm install net

and npm install dgram

but after that the problem with the dgram module still remain:

ERROR in C:/Users/Sibo//coap/lib/agent.js
Module not found: Error: Cannot resolve module 'dgram' in C:\Users\Sibo\node_modules\coap\lib
@ C:/Users/Sibo//coap/lib/agent.js 12:22-38

ERROR in C:/Users/Sibo//coap/lib/server.js
Module not found: Error: Cannot resolve module 'dgram' in C:\Users\Sibo\node_modules\coap\lib
@ C:/Users/Sibo//coap/lib/server.js 11:22-38

@shockey
Copy link
Contributor

shockey commented Jun 27, 2017

Hey @SimCordy, are you still having problems with this? Sorry for my delay.

Editing files in node_modules isn't really a good idea (see this StackOverflow answer), npm does a lot of magic in there.

If you want to include your modified version of swagger-client in swagger-ui, it'd be best to use npm link, like this:

# run this in your swagger-ui directory
npm link ./path/to/your/modified/swagger-client/directory
npm run build

npm will symlink your modified swagger-client into swagger-ui/node_modules/swagger-client for you, and you should have fresh swagger-ui files in swagger-ui/dist that you can use.

Let me know if this helps. Thanks for using Swagger!

@SimCordy
Copy link
Author

Hi, yes finally I resolved. The problem was caused by a library that I used in the modified source code, so I made some changes and then it worked.
In order to incorporate my modified swagger-js into swagger-ui, I have followed those steps:

  • Build the swagger-js library with npm run build;

  • I have replaced the node_modules/swagger-client/dist folder in the in the swagger-ui folder, with the dist folder genereted with the command in the previous step;

  • Finally, I rebuilt swagger-ui with the npm run build command;

This method works but require a lot of copy paste from one folder to another, probably the method that you suggested is better.

Thank you.

@shockey
Copy link
Contributor

shockey commented Jun 27, 2017

Awesome, glad you got it figured out. Feel free to open a ticket with any other questions you have.

Thanks for using Swagger!

@shockey shockey closed this as completed Jun 27, 2017
@lock lock bot locked and limited conversation to collaborators Jul 3, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

2 participants