当前位置: 首页 > 工具软件 > npm-publish > 使用案例 >

linux下安装nodejs出现 npm-cli.js: No such file or director 的真正解决方案

董意蕴
2023-12-01

按照网上百度到的其他去安装nodejs报错

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

然后继续百度 说是软连接问题,修改后继续报错

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    completion, config, create, ddp, dedupe, deprecate,
    dist-tag, docs, doctor, edit, explore, get, help,
    help-search, hook, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, profile, prune, publish, rb, rebuild, repo, restart,
    root, run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@6.4.1 /app/nodejs/lib/node_modules/npm

面向百度编程,各种深坑不多叙述,终于找到一个有用的文章

最后发现是因为安装包的问题,没有在linux下解压,导致npm和node 多了 38字节

最后在linux 下安装并配置好环境就成功了

tar -xJvf node-v10.16.3-linux-x64.tar.xz
vim /etc/profile
export NODE_HOME=/usr/local/node-v10.15.3-linux-x64
export PATH=$PATH:$NODE_HOME/bin

最后不要忘记
**输入 source /etc/profile 使设置生效

 node -v
v12.16.1

 npm -v
6.13.4

成功,感谢文章原作者

 类似资料: