0

I installed serverless framework to create some infrastructure code. I needed to update my version of npm after I udpated I now get this error message every time zsh starts.

This does not happen with sh or bash.

garrett ~ % zsh
/usr/local/lib/node_modules/npm/lib/cli.js:2
module.exports = async process => {
                       ^^^^^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:1)
    at Module._compile (module.js:570:32)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v6.9.2 --silent` to unset it.
garrett ~ % npm -v
8.15.0
garrett ~ % nvm --version
0.35.3
garrett ~ % cat .zshrc
source ~/.bash_profile
PS1='garrett %~ %# '

test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

garrett ~ % cat .bash_profile
# Added by ./setup - se_profile
# export SE_SHELL=bash
alias python="python3"
alias pip="pip3"
source "/Users/USER/Software/sportsengine/bin/se_profile"

export LSCOLORS="Exfxcxdxbxegedabagacad"
alias ls='ls -alGH'

alias notify='terminal-notifier -title "Terminal" -message "Done with task! Exit status: $?"' -activate com.apple.Terminal

After researching, the advice on this post does not work nvm is not compatible with the npm config "prefix" option:

$ npm config delete prefix 
$ npm config set prefix $NVM_DIR/versions/node/v6.11.1

I also followed the steps outlined in this answer

This may be a conflict with your local installation of Node (if you had it installed via another way than NVM in the past). You should delete this instance of node:

remove node_modules sudo rm -rf /usr/local/lib/node_modules

remove node sudo rm /usr/local/bin/node

remove node link cd /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print$9}'| xargs rm After you cant install nvm

Although the error message is gone, I no longer have npm installed.

When I install npm with brew install npm I'm at the same problem outlined above.

Marlon Richert
  • 5,250
  • 1
  • 18
  • 27
Garrett
  • 319
  • 1
  • 13
  • 1
    Why on earth are you doing `source ~/.bash_profile` inside your `.zshrc` file? Zsh code is not a superset of bash code. No wonder your Zsh is acting weirdly. – Marlon Richert Sep 03 '22 at 08:33
  • @MarlonRichert still learning obviously. thanks for the advice. – Garrett Sep 06 '22 at 19:11

0 Answers0