由于npm,无法刷新我的.zshrc文件

问题描述 投票:0回答:1

我尝试通过以下方式刷新我的.zshrc文件:

$ source .zshrc

但是我在我的root用户文件夹中找到了关于查找package.json文件的npm(我不知道在这种情况下与npm的连接)的奇怪错误。我不知道为什么源命令触发npm的东西以及为什么npm认为我的用户文件夹是一个npm项目。

我是npm和zshrc的新手,请帮忙:/

这是错误:

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

这是日志:

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 [email protected]
3 info using [email protected]
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 ]

这是我的.zshrc文件内容:

# 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"
npm zsh oh-my-zsh zshrc zsh-alias
1个回答
0
投票

解决了评论中的问题,因此将其作为答案添加。

线source $ZSH/oh-my-zsh.sh导致问题。

删除此行,它应该工作正常。

Edit:

在上述情况下source $ZSH/oh-my-zsh.sh的问题是package.json文件丢失,因此失败了。 正如@nzajt所提到的,删除该行会解决上述情况中的问题,但是如果你使用的是oh-my-zsh,那么它就行不通了。

© www.soinside.com 2019 - 2024. All rights reserved.