简体   繁体   English

无法识别全局安装的 NPM 包

[英]Globally installed NPM packages not recognised

I had a system crash.我遇到了系统崩溃。 While trying to fix it, I deleted a few files and (I may be wrong here), I deleted ~/.profile file among them.在尝试修复它时,我删除了一些文件(我可能在这里错了),我删除了其中的~/.profile文件。

After system restore, my globally installed npm packages are not working.系统还原后,我全局安装的 npm 包不起作用。

I uninstalled npm and node and installed the latest version of nodejs 16.x, and then reinstalled globally required npm packages, however, they are still not working.我卸载了 npm 和 node 并安装了最新版本的 nodejs 16.x,然后重新安装了全局所需的 npm 包,但是它们仍然无法正常工作。 Somewhere the environment variables (in .profile file?) have gone missing.某处环境变量(在 .profile 文件中?)丢失了。

How can I get the globally installed packages to run?如何让全局安装的软件包运行?

You are missing the path to the globally installed npm modules in your PATH .您在PATH中缺少全局安装的 npm 模块的PATH There are multiple fixes described on this page , one of which: 此页面上描述了多个修复程序,其中之一:

Open or create a ~/.profile file and add this line:打开或创建一个 ~/.profile 文件并添加以下行:
export PATH=~/.npm-global/bin:$PATH
Back on the command line, update your system variables:回到命令行,更新您的系统变量:
source ~/.profile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM