cli
cli copied to clipboard
`npm edit` bug when editor path has a space in it
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:
- the npmrc ini syntax was not supporting the empty space
- 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+
https://github.com/npm/cli/blob/22731831e22011e32fa0ca12178e242c2ee2b33d/lib/commands/edit.js#L52