linux shell 安装curl,bash – 不能使用curl安装NPM
尝试安装NPM时收到此错误。对此错误的任何帮助都非常感激。
$ curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 85 0 85 0 0 2226 0 --:--:-- --:--:-- --:--:-- 4473
sh: line 1: Syntax error near unexpected token `newline'
sh: line 1: `Moved: https://npmjs.org/install.sh'
更改命令从http:// … – > https://仍然没有运气。
其他信息:
操作系统:Mac OSX 10.8.2
CURL:curl 7.24.0(x86_64-apple-darwin12.0)
所以我试图安装作为一个超级用户,并迅速地遇到了这个山的文本。我完全迷失在这里
$ sudo curl https://npmjs.org/install.sh | sh
Password:
#!/bin/sh
# A word about this shell script:
#
# It must work everywhere,including on systems that lack
# a /bin/bash,map 'sh' to ksh,ksh97,bash,ash,or zsh,# and potentially have either a posix shell or bourne
# shell living at /bin/sh.
#
# See this helpful document on writing portable shell scripts:
# http://www.gnu.org/s/hello/manual/autoconf/Portable-Shell.html
#
# The only shell it won't ever work on is cmd.exe.
if [ "x$0" = "xsh" ]; then
# run as curl | sh
# on some systems,you can just do cat>npm-install.sh
# which is a bit cuter. But on others,&1 is already closed,# so catting to another script file won't do anything.
curl -s https://npmjs.org/install.sh > npm-install-$$.sh
sh npm-install-$$.sh
ret=$?
rm npm-install-$$.sh
exit $ret
fi
# See what "npm_config_*" things there are in the env,# and make them permanent.
# If this fails,it's not such a big deal.
configures="`env | grep 'npm_config_' | sed -e 's|^npm_config_||g'`"
npm_config_loglevel="error"
if [ "x$npm_debug" = "x" ]; then
(exit 0)
else
echo "Running in debug mode."
echo "Note that this requires bash or zsh."
set -o xtrace
set -o pipefail
npm_config_loglevel="verbose"
fi
export npm_config_loglevel
# make sure that node exists
node=`which node 2>&1`
ret=$?
if [ $ret -eq 0 ] && [ -x "$node" ]; then
(exit 0)
else
echo "npm cannot be installed without nodejs." >&2
echo "Install node first,and then try again." >&2
echo "" >&2
echo "Maybe node is installed,but not in the PATH?" >&2
echo "Note that running as sudo can change envs." >&2
echo ""
echo "PATH=$PATH" >&2
exit $ret
fi
# set the temp dir
TMP="${TMPDIR}"
if [ "x$TMP" = "x" ]; then
TMP="/tmp"
fi
TMP="${TMP}/npm.$$"
rm -rf "$TMP" || true
mkdir "$TMP"
if [ $? -ne 0 ]; then
echo "Failed to mkdir $TMP" >&2
exit 1
fi
BACK="$PWD"
ret=0
tar="${TAR}"
if [ -z "$tar" ]; then
tar="${npm_config_tar}"
fi
if [ -z "$tar" ]; then
tar=`which tar 2>&1`
ret=$?
fi
if [ $ret -eq 0 ] && [ -x "$tar" ]; then
echo "tar=$tar"
echo "version:"
$tar --version
ret=$?
fi
if [ $ret -eq 0 ]; then
(exit 0)
else
echo "No suitable tar program found."
exit 1
fi
# Try to find a suitable make
# If the MAKE environment var is set,use that.
# otherwise,try to find gmake,and then make.
# If no make is found,then just execute the necessary commands.
# XXX For some reason,make is building all the docs every time. This
# is an annoying source of bugs. Figure out why this happens.
MAKE=NOMAKE
if [ "x$MAKE" = "x" ]; then
make=`which gmake 2>&1`
if [ $? -eq 0 ] && [ -x $make ]; then
(exit 0)
else
make=`which make 2>&1`
if [ $? -eq 0 ] && [ -x $make ]; then
(exit 0)
else
make=NOMAKE
fi
fi
else
make="$MAKE"
fi
if [ -x "$make" ]; then
(exit 0)
else
# echo "Installing without make. This may fail." >&2
make=NOMAKE
fi
# If there's no bash,then don't even try to clean
if [ -x "/bin/bash" ]; then
(exit 0)
else
clean="no"
fi
node_version=`"$node" --version 2>&1`
ret=$?
if [ $ret -ne 0 ]; then
echo "You need node to run this program." >&2
echo "node --version reports: $node_version" >&2
echo "with exit code = $ret" >&2
echo "Please install node before continuing." >&2
exit $ret
fi
t="${npm_install}"
if [ -z "$t" ]; then
# switch based on node version.
# note that we can only use strict sh-compatible patterns here.
case $node_version in
0.[0123].* | v0.[0123].*)
echo "You are using an outdated and unsupported version of" >&2
echo "node ($node_version). Please update node and try again." >&2
exit 99
;;
v0.[45].* | 0.[45].*)
echo "install npm@1.0"
t=1.0
;;
v0.[678].* | 0.[678].*)
echo "install npm@1.1"
t=1.1
;;
*)
echo "install npm@latest"
t="latest"
;;
esac
fi
# the npmca cert
cacert='
-----BEGIN CERTIFICATE-----
MIIChzCCAfACCQDauvz/KHp8ejANBgkqhkiG9w0BAQUFADCBhzELMAkGA1UEBhMC
VVMxCzAJBgNVBAgTAkNBMRAwDgYDVQQHEwdPYWtsYW5kMQwwCgYDVQQKEwNucG0x
IjAgBgNVBAsTGW5wbSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxDjAMBgNVBAMTBW5w
bUNBMRcwFQYJKoZIhvcNAQkBFghpQGl6cy5tZTAeFw0xMTA5MDUwMTQ3MTdaFw0y
MTA5MDIwMTQ3MTdaMIGHMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEDAOBgNV
BAcTB09ha2xhbmQxDDAKBgNVBAoTA25wbTEiMCAGA1UECxMZbnBtIENlcnRpZmlj
YXRlIEF1dGhvcml0eTEOMAwGA1UEAxMFbnBtQ0ExFzAVBgkqhkiG9w0BCQEWCGlA
aXpzLm1lMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDLI4tIqPpRW+ACw9GE
OgBlJZwK5f8nnKCLK629Pv5yJpQKs3DENExAyOgDcyaF0HD0zk8zTp+ZsLaNdKOz
Gn2U181KGprGKAXP6DU6ByOJDWmTlY6+Ad1laYT0m64fERSpHw/hjD3D+iX4aMOl
y0HdbT5m1ZGh6SJz3ZqxavhHLQIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAC4ySDbC
l7W1WpLmtLGEQ/yuMLUf6Jy/vr+CRp4h+UzL+IQpCv8FfxsYE7dhf/bmWTEupBkv
yNL18lipt2jSvR3v6oAHAReotvdjqhxddpe5Holns6EQd1/xEZ7sB1YhQKJtvUrl
ZNufy1Jf1r0ldEGeA+0ISck7s+xSh9rQD2Op
-----END CERTIFICATE-----
'
echo "$cacert" > "$TMP/cafile.crt"
cacert="$TMP/cafile.crt"
# need to echo "" after,because Posix sed doesn't treat EOF
# as an implied end of line.
url=`(curl -SsL --cacert "$cacert" https://registry.npmjs.org/npm/$t; echo "") \
| sed -e 's/^.*tarball":"//' \
| sed -e 's/".*$//'`
ret=$?
if [ "x$url" = "x" ]; then
ret=125
# try without the -e arg to sed.
url=`(curl -SsL --cacert "$cacert" https://registry.npmjs.org/npm/$t; echo "") \
| sed 's/^.*tarball":"//' \
| sed 's/".*$//'`
ret=$?
if [ "x$url" = "x" ]; then
ret=125
fi
fi
if [ $ret -ne 0 ]; then
echo "Failed to get tarball url for npm/$t" >&2
exit $ret
fi
echo "fetching: $url" >&2
cd "$TMP" \
&& curl -SsL --cacert "$cacert" "$url" \
| $tar -xzf - \
&& rm "$cacert" \
&& cd "$TMP"/* \
&& (req=`"$node" bin/read-package-json.js package.json engines.node`
if [ -d node_modules ]; then
"$node" node_modules/semver/bin/semver -v "$node_version" -r "$req"
ret=$?
else
"$node" bin/semver.js -v "$node_version" -r "$req"
ret=$?
fi
if [ $ret -ne 0 ]; then
echo "You need node $req to run this program." >&2
echo "node --version reports: $node_version" >&2
echo "Please upgrade node before continuing." >&2
exit $ret
fi) \
&& (ver=`"$node" bin/read-package-json.js package.json version`
isnpm10=0
if [ $ret -eq 0 ]; then
req=`"$node" bin/read-package-json.js package.json engines.node`
if [ -d node_modules ]; then
if "$node" node_modules/semver/bin/semver -v "$ver" -r "1"
then
isnpm10=1
fi
else
if "$node" bin/semver -v "$ver" -r ">=1.0"; then
isnpm10=1
fi
fi
fi
ret=0
if [ $isnpm10 -eq 1 ] && [ -f "scripts/clean-old.sh" ]; then
if [ "x$skipclean" = "x" ]; then
(exit 0)
else
clean=no
fi
if [ "x$clean" = "xno" ] \
|| [ "x$clean" = "xn" ]; then
echo "Skipping 0.x cruft clean" >&2
ret=0
elif [ "x$clean" = "xy" ] || [ "x$clean" = "xyes" ]; then
NODE="$node" /bin/bash "scripts/clean-old.sh" "-y"
ret=$?
else
NODE="$node" /bin/bash "scripts/clean-old.sh"
ret=$?
fi
fi
if [ $ret -ne 0 ]; then
echo "Aborted 0.x cleanup. Exiting." >&2
exit $ret
fi) \
&& (if [ "x$configures" = "x" ]; then
(exit 0)
else
echo "./configure "$configures
echo "$configures" > npmrc
fi) \
&& (if [ "$make" = "NOMAKE" ]; then
(exit 0)
elif "$make" uninstall install; then
(exit 0)
else
make="NOMAKE"
fi
if [ "$make" = "NOMAKE" ]; then
"$node" cli.js rm npm -gf
"$node" cli.js install -gf
fi) \
&& cd "$BACK" \
&& rm -rf "$TMP" \
&& echo "It worked"
ret=$?
if [ $ret -ne 0 ]; then
echo "It Failed" >&2
fi
exit $ret
linux shell 安装curl,bash – 不能使用curl安装NPM相关推荐
- linux shell脚本 wget,bash – 在shell脚本中运行wget和其他命令
以下是编写shell脚本时要使用的一些准则. >使用它们时始终引用变量.这有助于避免误解的可能性. (如果文件名包含空格怎么办?) >不要相信像rm这样的命令上的文件加载.请改用循环. ( ...
- linux shell 函数库,bash shell 函数库
bash shell 函数库ash由自由软件基金会,Inc.版权所有(C) 1989-2011. 语法 bash [options] [file] 描述 Bash是一种与sh兼容的命令语言解释器,它执 ...
- linux shell #[感叹号]/bin/bash 是什么意思?
垃圾CSDN,标题里感叹号都发不出来! 文章目录 #!/bin/bash简介 1)`#!/bin/bash`只能放在第一行,如果后面还有`#!`,那么只能看成是注释. 2)#!后面的路径一定要正确,不 ...
- linux shell 鼠标事件,Bash Shellshock事件:CVE-2014-6271资料汇总
法国GNU/Linux爱好者Stéphane Chazelas于2014年9月中旬发现了著名SHELL实现BASH的一个漏洞,你可以通过构造环境变量的值来执行你想要执行的脚本代码,据报道称,这个漏洞能 ...
- linux shell 一行 for,BASH shell脚本回显到同一行输出
我有一个简单的BASH shell脚本,它检查curl命令的HTTP响应代码. 逻辑很好,但我坚持"简单地"打印出"输出". 我正在使用GNU bash,版本3 ...
- linux shell 数组对比,bash shell之数组使用(牛逼篇)
这次写脚本时用到了bash shell数组,当初做法是配置文件里面写成数组形式A=(element1 element2 element3 .... element4),然后一个脚本读取这个配置文件,于 ...
- linux shell 获取表,bash - 如何获取shell脚本中目录中的文件列表?
bash - 如何获取shell脚本中目录中的文件列表? 我试图使用shell脚本获取目录的内容. 我的脚本是: for entry in `ls $search_dir`; do echo $ent ...
- linux shell declare -a,Bash Shell之declare定义变量
实验环境 ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) 命令说明 declare 与 typeset 命令都是bas ...
- linux shell 字符串 数组,bash shell函数返回数组字符串
#!/bin/bash # script:getselfvar.sh # 每个脚本中都在末尾追加了一段特殊的域名ip序列,需要将这段序列存放到数组变量中,供 # 脚本使用,例子中的ip和域名是处理过的 ...
最新文章
- libgstreamer-1.0.so.0: cannot open shared object file: No such file or directory
- oracle 存储怎么使用,Oracle存储过程中如何使用数组(附范例)
- java乌龟_java用swing画可以行走的乌龟
- 1748. The Most Complex Number/LG的数学计划~~~持续更新ing(反素数求解)
- 初试 Git hooks 自动部署
- 你该学点HTML/CSS知识的9大理由
- RK3399封装(CPU+GPU)Mali-T860 Codec架构(十六)
- Ext.js入门:TabPanel组件(八)
- 终极算法【5】——进化学派
- opencv python 常用方法
- TFT-液晶显示屏的结构和原理
- 招银网络---C++
- 什么蓝牙耳机颜值高音质好?颜值高音质好的蓝牙耳机推荐
- 实验三 基于A*迷宫的算法
- 给在读研究生+未来要读研同学们的一封受益匪浅的信
- 【MATLAB】进阶绘图 ( Pie Chart 饼图 | pie 函数 | 三维饼图 | pie3 函数 )
- mos管的rc吸收电路计算_RCD吸收电路
- python处理excel文件有哪些常用的库?
- 【算法竞赛学习笔记】状压DP
- 在PCB中快速找到原理图的原件
热门文章
- 春考天津计算机知识点资料,天津春季高考统一考试计算机基础科目考试大纲
- 问题解决:Invalid version number:Version number may be negative or greater than 255
- 【CVE-2021-4034】 漏洞详细原理以及复现,polkit的pkexec中的本地提权漏洞
- 混战多年,K12在线教育的故事讲到哪了?
- android模拟器启动boss,传说之下boss模拟器无敌版
- 系统开发视角下的诊断 ———— 动力系统(P)诊断故障6
- python+selenium移动滑块代码【杭州多测师_王sir】【杭州多测师】
- HTML期末作业-我的大学生活网页
- 命令启动edge浏览器且全屏
- 装服务器系统时无法找到介质,服务器安装介质未找到