mac小程序云开发时开启云函数本地调试提示安装node_modules点击安装会出现此错误,求解?
操作系统: Mac 开发工具版本号: 稳定版 Stable Build (1.06.2306020) 错误信息: > Executing task: npm install < env: node: No such file or directory The terminal process "/bin/zsh '-c', 'npm install'" terminated with exit code: 127. 使用终端安装没有此问题,本地安装完成后运行不了云函数本地调试 以下方法都试过了没有解决此问题: The problem is your npm scripts in vscode is started with [代码]/bin/zsh -c[代码] (non-login non-interactive) This means scripts inside ~/.zshrc is not executed (and for the same reason ~/.zprofile). However, even in non-login non-interactive mode, ~/.zshenv is loaded. Solution 1: Change "npm.packageManager": to npm
Make sure you restart vscode to make this take into effect.
Solution 2 (preferred): Open ~/.zshrc and move whatever scripts that is loading yarn into ~/.zshenv
In my specific case, my yarn is installed through npm [代码]npm i -g yarn[代码] and my npm is installed through nvm. So I had to move following two lines. export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Solution 3: Don't use VSCode's npm scripts. You can actually execute by opening terminal yourself shortcut ctrl + ` and typing out yarn "npm script name".