简体   繁体   English

Ionic - 即使安装了 npm,npm 也不会被识别为内部命令

[英]Ionic - npm is not recognized as an interal command, even with npm installed

I am running into a bit of trouble installing a couple ionic cordova native plugins.我在安装几个 ionic cordova 本机插件时遇到了一些麻烦。

Basically if I type npm in my cmd I get the npm cli, if I type ionic I get the ionic cli, if I type cordova I get the cordova cli but:基本上,如果我在我的 cmd 中输入npm我得到 npm cli,如果我输入ionic我得到 ionic cli,如果我输入cordova我得到cordova cli 但是:

If I type ionic cordova plugin add cordova-plugin-camera如果我输入ionic cordova plugin add cordova-plugin-camera

I get Error: cmd: Command failed with exit code 1 Error output: 'C:\\WINDOWS\\system32\\npm' is not recognized as an internal or external command, operable program or batch file.我收到错误:cmd:命令失败,退出代码 1 错误输出:'C:\\WINDOWS\\system32\\npm' 不是内部或外部命令、可运行的程序或批处理文件。

C:\\WINDOWS\\system32\\npm is not in my enviroment var path nor is nodejs or npm installed there, so why would the ionic cli look for it there? C:\\WINDOWS\\system32\\npm 不在我的环境 var 路径中,也没有安装 nodejs 或 npm,那么为什么 ionic cli 会在那里寻找它?

With Ionic the version of npm is very sensitive. 使用Ionic,npm的版本非常敏感。 Not all npm versions work, especially the latest (which ever) always give me troubles. 并非所有npm版本都能正常工作,尤其是最新版本(一直以来)总是给我带来麻烦。

  1. npm i -g npm@5.0.4 (or try a few others if this one breaks) npm i -g npm@5.0.4(如果此操作失败,则尝试其他操作)

  2. Deleting/renaming your package-lock.json makes the occasional difference. 删除/重命名package-lock.json有时会有所不同。

  3. Delete node_modules and retype npm install 删除node_modules并重新输入npm install

Those 3 work for me. 那三个对我有用。

Download node.js下载 node.js

First of all Download and install node.js from here Nodejs.org首先从这里下载并安装 node.js Nodejs.org

In windows 10在 Windows 10 中

1. Go to My Computer properties 1.进入我的电脑属性

2. Click Advanced system settings 2.点击高级系统设置

3. Now you are on System Properties window, Click advanced 3.现在你在系统属性窗口,点击高级

4. Then, click Environment Variable button 4.然后,单击环境变量按钮

5. From System Variable, Select Path 5.从系统变量中,选择路径

6. click Edit 6.点击编辑

7. At the end of the Variable value, add ;C:\\Program Files\\node.js\\ 7. 在 Variable 值的末尾,添加;C:\\Program Files\\node.js\\

8. Click Ok all the open dialogue box 8.点击确定所有打开的对话框

Reference: Fix ~ npm not recognized as internal or external command (Note: this is my own blog[include images also)参考: 修复~ npm 不被识别为内部或外部命令(注意:这是我自己的博客[也包括图像)

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

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