如何使用 visual-studio-code 编辑 npm 配置文件?

How to edit npm config file with visual-studio-code?

npm 配置的默认编辑器是 vi。阅读此文档后:https://docs.npmjs.com/misc/config#editor

☁  nodejs-project  npm get editor
vi

现在,我想使用 visual-studio-code

编辑 npm 配置

因此,我将 npm 编辑器设置为 visual-studio-code,如下所示:

☁  nodejs-project  npm set editor visual-studio-code
☁  nodejs-project  npm get editor
visual-studio-code

并且,尝试这个命令,得到一个错误:

☁  nodejs-project  npm config edit
npm ERR! path visual-studio-code
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn visual-studio-code
npm ERR! enoent spawn visual-studio-code ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ldu020/.npm/_logs/2019-01-18T03_00_59_872Z-debug.log

检查 vscode 二进制文件:

☁  nodejs-project  brew cask info visual-studio-code
visual-studio-code: 1.30.2,61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8 (auto_updates)
https://code.visualstudio.com/
/usr/local/Caskroom/visual-studio-code/1.22.2,3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9 (64B)
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/visual-studio-code.rb
==> Names
Microsoft Visual Studio Code
VS Code
==> Artifacts
Visual Studio Code.app (App)
/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code (Binary)

它应该将 npm 编辑器设置为 code,而不是 visual-studio-code

☁  nodejs-project  npm set editor code
☁  nodejs-project  npm get editor
code

现在,npm config edit 将使用 vscode 打开 .npmrc 文件。