1

I try to refresh my .zshrc file by:

$ source .zshrc

but I get weird errors from npm (I don't know the connection to npm on this situation) about looking for package.json file inside my root user folder. I don't why the source command trigger something of npm and why npm think that my user folder is an npm project.

I am new to npm and zshrc, please help :/

here are the errors:

npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/omrita/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/omrita/package.json'
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/omrita/.npm/_logs/2019-01-21T16_49_34_718Z-debug.log
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/omrita/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/omrita/package.json'
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/omrita/.npm/_logs/2019-01-21T16_49_35_078Z-debug.log
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/omrita/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/omrita/package.json'
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/omrita/.npm/_logs/2019-01-21T16_49_35_436Z-debug.log
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/omrita/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/Users/omrita/package.json'
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/omrita/.npm/_logs/2019-01-21T16_49_35_768Z-debug.log

here are the logs:

0 info it worked if it ends with ok
1 verbose cli [ '/Users/omrita/nvm/versions/node/v11.1.0/bin/node',
1 verbose cli   '/Users/omrita/nvm/versions/node/v11.1.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test',
1 verbose cli   '-f',
1 verbose cli   '/Users/omrita/.oh-my-zsh/plugins/git/_git' ]
2 info using npm@6.4.1
3 info using node@v11.1.0
4 verbose config Skipping project config: /Users/omrita/.npmrc. (matches userconfig)
5 warn using --force I sure hope you know what you are doing.
6 verbose stack Error: ENOENT: no such file or directory, open '/Users/omrita/package.json'
7 verbose cwd /Users/omrita
8 verbose Darwin 17.7.0
9 verbose argv "/Users/omrita/nvm/versions/node/v11.1.0/bin/node" "/Users/omrita/nvm/versions/node/v11.1.0/bin/npm" "run" "test" "-f" "/Users/omrita/.oh-my-zsh/plugins/git/_git"
10 verbose node v11.1.0
11 verbose npm  v6.4.1
12 error path /Users/omrita/package.json
13 error code ENOENT
14 error errno -2
15 error syscall open
16 error enoent ENOENT: no such file or directory, open '/Users/omrita/package.json'
17 error enoent This is related to npm not being able to find a file.
18 verbose exit [ -2, true ]

This is my .zshrc file content:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
source /Users/omrita/.bash_profile
export ZSH="/Users/omrita/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="robbyrussell"

# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )

# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
  git
)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"


alias alias-r="cd ~ && source .zshrc"
alias add-alias="open ~/.zshrc"

alias npm-private="npm config set registry http://npm.dev.wixpress.com/"
alias npm-public="npm config set registry https://registry.npmjs.org/"

alias clean-install="watchman watch-del-all && rm -rf node_modules && rm -f package-lock.json && npm i"
alias clean-cash="watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache"

alias ios="react-native run-ios"
alias android="react-native run-android"
alias rn-init="react-native init"

alias developer="cd /Users/omrita/Documents/Developer"
alias rn="cd /Users/omrita/Documents/Developer/react-native"

alias gs="git status"
alias pull="git pull"
alias push="git push"
alias npminstall="npm install"
alias wix="cd /Users/omrita/Documents/Developer/wix"
alias oneapp="cd /Users/omrita/Documents/Developer/wix/wix-one-app"

alias runl="npm run launch"

alias ws="open -a /Applications/WebStorm.app ."
alias scripts="cat package.json | jq -r '.scripts'"
alias editReadme="open -a /Applications/MacDown.app README.md"
alias hgrep="history | grep $1"
alias rns="adb reverse tcp:8081 tcp:8081 && watchman watch-del-all && react-native start"
alias ios-x="react-native run-ios --simulator='iPhone X'"
alias rvrs="adb reverse tcp:8081 tcp:8081"
alias as='open -a /Applications/Android\ Studio.app ./android'
alias rr="adb shell am broadcast -a react.native.RELOAD"
alias invites="cd /Users/omrita/Documents/Developer/wix/wix-one-app-invites/wix-one-app-invites"
alias platform="cd /Users/omrita/Documents/Developer/wix/wix-one-app-platform"
alias kill="killall node"
alias test="npm run test"
alias account="cd /Users/omrita/Documents/Developer/wix/wix-one-app-account"
alias oneapp="cd /Users/omrita/Documents/Developer/wix/wix-one-app"
alias master="git checkout master"
omri tal
  • 98
  • 8

1 Answers1

0

Resolved the issue in the comments and hence adding this as an answer.

The line source $ZSH/oh-my-zsh.sh is causing the problem.

Remove this line and it should work fine.

Edit:

The issue with source $ZSH/oh-my-zsh.sh in the above case is that the package.json file is missing and hence its failing.
As mentioned by @nzajt, Removing the line would fix the problem in the above case, but if you're using oh-my-zsh, then it wouldn't work.

Community
  • 1
  • 1
Ashwin Valento
  • 878
  • 1
  • 7
  • 14
  • 1
    I don't think this should be the answer, removing `source $ZSH/oh-my-zsh.sh` will cause oh-my-zsh to stop working, and I don't think that is a good solution. The issue is with npm. the error `npm ERR! path /Users/omrita/package.json` shows that npm hasn't been setup correctly. – nzajt Feb 13 '19 at 22:27
  • @nzajt , Yes , the root issue is with a file which does not exist. According to the logs provided, it looks like the package.json file is missing. This was probably because the OMzsh direcoty was deleted but the script is still trying to access that directory. – Ashwin Valento Feb 15 '19 at 12:32
  • the file that is missing is `/Users/omrita/package.json` if it was an issue with Oh My Zsh, the missing file would have been in `/Users/omrita/.oh-my-zsh`. Removing that line didn't fix the issue it just stopped that error message, and the real issue with npm was never solved. – nzajt Feb 15 '19 at 16:39