npm
配置的默认编辑器是vi
。阅读此文档后:https://docs.npmjs.com/misc/config#editor
☁ nodejs-project npm get editor
vi
现在,我想使用npm
来编辑visual-studio-code
配置
因此,我将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
答案 0 :(得分:0)
检查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
文件。