Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

npm edit bug when editor path has a space in it #7606

Open
borracciaBlu opened this issue Jun 21, 2024 · 0 comments
Open

npm edit bug when editor path has a space in it #7606

borracciaBlu opened this issue Jun 21, 2024 · 0 comments
Labels
Priority 2 secondary priority issue

Comments

@borracciaBlu
Copy link

in .npmrc add a path to an editor with an empty space in it

editor=/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl

or

editor=/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code

then on npm edit

➜ npm edit read
npm ERR! code ENOENT
npm ERR! syscall spawn /Applications/Sublime
npm ERR! path /Applications/Sublime
npm ERR! errno -2
npm ERR! enoent spawn /Applications/Sublime ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

So, when i saw this i thought about 2 possibles issue:

  1. the npmrc ini syntax was not supporting the empty space
  2. spawn was not able to deal with the empty space

npmrc npm/ini

I've tried in runkit and seems fine

var ini = require("ini")

const a = ini.decode("editor=/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl")

spawn
I've tried in node and seems fine too

const { spawn } = require('node:child_process');
spawn("/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl")

Thus I believe this to be the line that cause the issue as it's looking for \s+

const [bin, ...spawnArgs] = this.npm.config.get('editor').split(/\s+/)

@milaninfy milaninfy added the Priority 2 secondary priority issue label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 2 secondary priority issue
2 participants