nodejs 6.9.1安装完成后,验证npm是否安装成功时提示:

bin/npm: line 1: ../lib/node_modules/npm/bin/npm-cli.js: No such file or directory 

解决办法:

//运行安装npm的脚本
curl https://npmjs.org/install.sh | sudo sh

如果执行以下命令不行,则可以把install.sh下载下来,放到node目录下执行。

install.sh文件内容如下:

#!/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.# Follow Location: headers, and fail on errorscurl -f -L -s https://www.npmjs.org/install.sh > npm-install-$$.shret=$?if [ $ret -eq 0 ]; then(exit 0)elserm npm-install-$$.shecho "Failed to download script" >&2exit $retfish npm-install-$$.shret=$?rm npm-install-$$.shexit $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)
elseecho "Running in debug mode."echo "Note that this requires bash or zsh."set -o xtraceset -o pipefailnpm_config_loglevel="verbose"
fi
export npm_config_loglevel# make sure that Node.js exists
node=`which node 2>&1`
ret=$?
if [ $ret -eq 0 ] && [ -x "$node" ]; then(exit 0)
elseecho "npm cannot be installed without Node.js." >&2echo "Install Node.js first, and then try again." >&2echo "" >&2echo "Maybe Node.js is installed, but not in the PATH?" >&2echo "Note that running as sudo can change envs." >&2echo ""echo "PATH=$PATH" >&2exit $ret
fi# set the temp dir
TMP="${TMPDIR}"
if [ "x$TMP" = "x" ]; thenTMP="/tmp"
fi
TMP="${TMP}/npm.$$"
rm -rf "$TMP" || true
mkdir "$TMP"
if [ $? -ne 0 ]; thenecho "failed to mkdir $TMP" >&2exit 1
fiBACK="$PWD"ret=0
tar="${TAR}"
if [ -z "$tar" ]; thentar="${npm_config_tar}"
fi
if [ -z "$tar" ]; thentar=`which tar 2>&1`ret=$?
fiif [ $ret -eq 0 ] && [ -x "$tar" ]; thenecho "tar=$tar"echo "version:"$tar --versionret=$?
fiif [ $ret -eq 0 ]; then(exit 0)
elseecho "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=NOMAKEif [ "x$MAKE" = "x" ]; thenmake=`which gmake 2>&1`if [ $? -eq 0 ] && [ -x "$make" ]; then(exit 0)elsemake=`which make 2>&1`if [ $? -eq 0 ] && [ -x "$make" ]; then(exit 0)elsemake=NOMAKEfifi
elsemake="$MAKE"
fiif [ -x "$make" ]; then(exit 0)
else# echo "Installing without make. This may fail." >&2make=NOMAKE
fi# If there's no bash, then don't even try to clean
if [ -x "/bin/bash" ]; then(exit 0)
elseclean="no"
finode_version=`"$node" --version 2>&1`
ret=$?
if [ $ret -ne 0 ]; thenecho "You need Node.js to run this program." >&2echo "node --version reports: $node_version" >&2echo "with exit code = $ret" >&2echo "Please install Node.js before continuing." >&2exit $ret
fit="${npm_install}"
if [ -z "$t" ]; then# switch based on Node.js version.# note that we can only use strict sh-compatible patterns here.case $node_version in0.[01234567].* | v0.[01234567].*)echo "You are using an outdated and unsupported version of" >&2echo "Node.js ($node_version).  Please update Node.js and try again." >&2exit 99;;*)echo "install npm@latest"t="latest";;esac
fi# need to echo "" after, because Posix sed doesn't treat EOF
# as an implied end of line.
url=`(curl -SsL https://registry.npmjs.org/npm/$t; echo "") \| sed -e 's/^.*tarball":"//' \| sed -e 's/".*$//'`ret=$?
if [ "x$url" = "x" ]; thenret=125# try without the -e arg to sed.url=`(curl -SsL https://registry.npmjs.org/npm/$t; echo "") \| sed 's/^.*tarball":"//' \| sed 's/".*$//'`ret=$?if [ "x$url" = "x" ]; thenret=125fi
fi
if [ $ret -ne 0 ]; thenecho "Failed to get tarball url for npm/$t" >&2exit $ret
fiecho "fetching: $url" >&2cd "$TMP" \&& curl -SsL "$url" \| $tar -xzf - \&& cd "$TMP"/* \&& (ver=`"$node" bin/read-package-json.js package.json version`isnpm10=0if [ $ret -eq 0 ]; thenif [ -d node_modules ]; thenif "$node" node_modules/semver/bin/semver -v "$ver" -r "1"thenisnpm10=1fielseif "$node" bin/semver -v "$ver" -r ">=1.0"; thenisnpm10=1fififiret=0if [ $isnpm10 -eq 1 ] && [ -f "scripts/clean-old.sh" ]; thenif [ "x$skipclean" = "x" ]; then(exit 0)elseclean=nofiif [ "x$clean" = "xno" ] \|| [ "x$clean" = "xn" ]; thenecho "Skipping 0.x cruft clean" >&2ret=0elif [ "x$clean" = "xy" ] || [ "x$clean" = "xyes" ]; thenNODE="$node" /bin/bash "scripts/clean-old.sh" "-y"ret=$?elseNODE="$node" /bin/bash "scripts/clean-old.sh" </dev/ttyret=$?fifiif [ $ret -ne 0 ]; thenecho "Aborted 0.x cleanup.  Exiting." >&2exit $retfi) \&& (if [ "x$configures" = "x" ]; then(exit 0)elseecho "./configure $configures"echo "$configures" > npmrcfi) \&& (if [ "$make" = "NOMAKE" ]; then(exit 0)elif "$make" uninstall install; then(exit 0)elsemake="NOMAKE"fiif [ "$make" = "NOMAKE" ]; then"$node" cli.js rm npm -gf"$node" cli.js install -gffi) \&& cd "$BACK" \&& rm -rf "$TMP" \&& echo "It worked"ret=$?
if [ $ret -ne 0 ]; thenecho "It failed" >&2
fi
exit $ret

本文作者:jiankunking,出处:http://blog.csdn.net/jiankunking/

npm 安装 bin/npm: line 1: ../lib/node_modules/npm/bin/npm-cli.js: No such file or directory相关推荐

  1. JDK1.3安装出现/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory Done.

    今天是出道以来第一次安装JDK1.3,大学的时候接触的也已是JDK1.4,而且是在Red Hat Enterprise Linux Server release 6.6上,安装JDK1.3是由于软件组 ...

  2. 【Linux】/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

    报错信息 -bash: /opt/sybase/OCS-15_0/bin/isql: /lib/ld-linux.so.2: bad ELF interpreter: No such file or ...

  3. linux 配置JAVA 环境问题(一)/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

    场景:在centOS8(64X)下配置java环境出现配置不上,提示:-bash: /usr/lib/java/jdk1.8.0_171/bin/java: /lib/ld-linux.so.2: b ...

  4. 修复/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory问题

    在64系统里执行32位程序如果出现/lib/ld-linux.so.2:  bad ELF interpreter: No such file or directory,安装下glic即可 #yum ...

  5. 解决/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory报错

    /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory 今天在搭建一台新服务器的java环境,配置完环境变量后输入java ...

  6. [Android NDK]修复/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory 问题

    原文:http://baoz.net/%E4%BF%AE%E5%A4%8Dlibld-linux-so-2-bad-elf-interpreter-no-such-file-or-directory- ...

  7. redhat6.4执行二进制程序报错:/lib/ld-linux.so.2: bad ELF interpreter: No such file or directory...

    redhat6.4执行二进制程序报错: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory 原因: 在64位的系统中执 ...

  8. modprobe:FATAL: could not load /lib/modules/2.6.35-22-generic/modules.dep No such file or directory

    给ubuntu升级到10.10 ,开机可能出现错误 modprobe:FATAL: could not load /lib/modules/2.6.35-22-generic/modules.dep ...

  9. 使用npm安装一些包失败了的看过来(npm国内镜像介绍)

    原文地址http://cnodejs.org/topic/4f9904f9407edba21468f31e 这个也是网上搜的,亲自试过,非常好用! 镜像使用方法(三种办法任意一种都能解决问题,建议使用 ...

最新文章

  1. 接口(interface)
  2. matlab 噪声检测,MATLAB应用在基于噪声检测的图像均值去噪法
  3. java匿名内部类举例和内部类举例
  4. flink 1-个人理解
  5. Linux下搭建iSCSI共享存储详细步骤(服务器模拟IPSAN存储)
  6. php生成缩略图填充白,php生成缩略图填充白边(等比缩略图方案)_PHP教程
  7. vim mark bookmarks使用
  8. AI为传统零售行业赋能,自助收银推动无人零售发展
  9. snmp trap 如何在浏览器中_SNMP TRAP功能
  10. MODIS数据下载及MRT批处理方法
  11. Eclipse 专用等宽字体,Yahei_Consola字体
  12. 计算机考研408每日一题 day158
  13. dispatch_apply快速迭代
  14. 赤峰市田家炳中学2021高考成绩查询,2021年常州各高中高考成绩排名及放榜最新消息...
  15. PXE网络安装linux系统
  16. 2022山东省安全员A证操作证考试题库模拟考试平台操作
  17. AID Learning设置aidcode的启动页面
  18. word文档生成系列:doc和docx插入多图
  19. 太贪玩 书到用时方恨少
  20. impala经验之谈

热门文章

  1. 课程设计:简单计算器的实现
  2. 数据分析出的 2000年以来高分华语电影前50名
  3. python生成文章标题_利用简书首页文章标题数据生成词云
  4. [rosrun] Couldn‘t find executable named xxx
  5. mac80211/cfg80211模块编译安装
  6. html把字母a显示为其asc码,HTML ASCII码
  7. 向量语义与静态词嵌入——从tf-idf到GloVe
  8. (飞机绕圈问题)每个飞机只有一个油箱,飞机之间可以相互加油(注意是相互,没有加油机)一箱油可供一架飞机绕地球飞半圈
  9. 即时通讯IM 源码 uniapp php 全开源
  10. 追加贷显示服务器出错,小蜜蜂财务软件常见问题汇总