swagger-editor-live icon indicating copy to clipboard operation
swagger-editor-live copied to clipboard

local npm install: "no such file or directory node_modules/swagger-editor-dist/"

Open khelkun opened this issue 8 years ago • 8 comments

I started to use swagger-editor-live and it does exactly what I was looking for swagger-editor version 3. It works but I had a strange issue that I wanted to report. Sorry if the issue is related to my environment but I don't think it is.

  • I installed swagger-editor-live locally to my project: npm install swagger-editor-live --save-dev
  • Then declared this script in my own package.json: "swagger:edit": "swagger-editor-live swagger/swagger.yaml --port=8000"
  • Then run it: npm run swagger:edit
  • And it complained about missing swagger-editor-dist dependcy in the swagger-editor-dist/node_modules:
Error: ENOENT: no such file or directory, stat '/home/me/myproject/node_modules/swagger-editor-live/node_modules/swagger-editor-dist/swagger-editor.css'
Error: ENOENT: no such file or directory, stat '/home/me/myproject/node_modules/swagger-editor-live/node_modules/swagger-editor-dist/swagger-editor-bundle.js'
Error: ENOENT: no such file or directory, stat '/home/me/myproject/node_modules/swagger-editor-live/node_modules/swagger-editor-dist/swagger-editor-standalone-preset.js'

Actually the only dependency that was existing in /home/me/myproject/node_modules/swagger-editor-live/node_modules/ was commander (weird). So I did that:

cd /home/me/myproject/node_modules/swagger-editor-live
npm install

And now everything's fine. I just wanted to let you know in case something would be wrong uin the npm released package of swagger-editor-live. If not then please forgive me and thanks for this useful module.

khelkun avatar Aug 24 '17 11:08 khelkun

I confirm this issue when installing the swagger-editor-live package locally But installing it globally works just fine

However I noticed that when I install it locally there's another module installed: /home/me/myproject/node_modules/swagger-editor-dist/ So I guess swagger-editor-live should rely on this locally installed swagger-editor-dist but considering the issue I reported it seems that it expects swagger-editor-dist to be in /home/me/myproject/node_modules/swagger-editor-live/node_modules/swagger-editor-dist

khelkun avatar Aug 24 '17 14:08 khelkun

I did not have this issue, but I will double check. Thank you for the report.

moon0326 avatar Aug 26 '17 00:08 moon0326

Did you remove the global installation of swagger-editor-live npm package before testing it?

this is what my package-lock.json shows:

"swagger-editor-live": {
      "version": "2.1.7",
      "resolved": "https://registry.npmjs.org/swagger-editor-live/-/swagger-editor-live-2.1.7.tgz",
      "integrity": "sha1-oz9+rjTXtoBy3WMGcqCSPXxJRW0=",
      "requires": {
        "commander": "2.11.0",
        "express": "4.15.4",
        "open": "0.0.5",
        "path": "0.12.7",
        "swagger-editor-dist": "3.1.5"
      },
      "dependencies": {
        "commander": {
          "version": "2.11.0",
          "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
          "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ=="
        }
      }
},

khelkun avatar Aug 28 '17 10:08 khelkun

Hi @khelkun

I've never tested it as a package of another package (your case). I only tested it as a global package.

I think I know what the issue is.

It looks like swagger-editor-live is looking for "swagger-editor-dist" in an incorrect path.

It should look for "swagger-editor-dist" in your "node_modules", but it's looking for that in /node_modules/swagger-editor-live/node_modules.

I will have patch soon.

Thank you for the report!

moon0326 avatar Aug 28 '17 12:08 moon0326

That's right, thank you for your time and this package which is really useful to me!

khelkun avatar Aug 28 '17 13:08 khelkun

@khelkun

Sorry for the delay in the fix.

I've just released 2.1.8 with a fix.

Thank you for the report again!

moon0326 avatar Sep 01 '17 02:09 moon0326

Thanks! the npm local install works fine now.

If you're interested in this, I tried npm & yarn and for some reason something goes wrong with yarn: it doesn't install swagger-editor-dist package and the yarn.lock file doesn't mention swagger-editor-dist as a dependency of swgger-editor-live. I don't now much about yarn but once again it can be related to my environment, yarn.lock:

swagger-editor-live@^2.1.8:
  version "2.2.1"
  resolved "https://registry.yarnpkg.com/swagger-editor-live/-/swagger-editor-live-2.2.1.tgz#22eff9bbca0a31defc3caf14d3e6e349226e6c04"
  dependencies:
    commander "^2.9.0"
    connect "^3.6.2"
    open "0.0.5"
    path "^0.12.7"
    serve-static "^1.12.3"

But package-lock.json of npm does mention swagger-editor-dist dependency:

    "swagger-editor-dist": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/swagger-editor-dist/-/swagger-editor-dist-3.1.5.tgz",
      "integrity": "sha1-CES6hp/B6bd9Em12HVwOBx2IPYg="
    },
    "swagger-editor-live": {
      "version": "2.1.8",
      "resolved": "https://registry.npmjs.org/swagger-editor-live/-/swagger-editor-live-2.1.8.tgz",
      "integrity": "sha1-IwwzrP1Jw53NjwDH8uM5PfGag+Q=",
      "requires": {
        "commander": "2.11.0",
        "express": "4.15.4",
        "open": "0.0.5",
        "path": "0.12.7",
        "swagger-editor-dist": "3.1.5"
      }

khelkun avatar Sep 01 '17 09:09 khelkun

@khelkun

That's interesting. I should start using yarn instead :) I guess old habit does not go away that easily.

I will try this over the weekend. Thank you for the report! I will leave it open until I figure out yarn issue.

moon0326 avatar Sep 01 '17 16:09 moon0326