为什么会出现这个错误?我已经安装了 node.js

时间:2021-03-14 11:12:42

标签: javascript node.js npm

因此,我在 Visual Studio Code - Insiders 的终端中输入 npm init,结果如下:

npm init
npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ npm init
+ ~~~
    + CategoryInfo          : ObjectNotFound: (npm:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我的 PC 上确实有最新版本的 node.js 和 VSC Insiders。任何帮助将不胜感激:)

2 个答案:

答案 0 :(得分:0)

这是因为系统无法进行节点打包。 您应该尝试在您的系统环境变量中设置下载的节点包的路径。

ilist[ic] = iw;

到系统属性上环境变量的“用户变量”部分的路径变量的末尾。

答案 1 :(得分:0)

尝试以下解决方案:

  1. import { cache } from '@emotion/css'; import { CacheProvider } from '@emotion/react'; export const wrapRootElement = ({ element }) => { return <CacheProvider value={cache}>{element}</CacheProvider>; }; 添加到您的 PATH 环境变量(替换为您的用户名)。要访问环境变量,请执行以下操作:
  • 打开“开始”菜单
  • 搜索“环境变量”
  • 选择“编辑系统环境变量”
  • 选择右下角的“环境变量...”
  • 双击上方框中的 PATH 变量(用户环境变量)
  1. 执行相同操作,但在安装 Node 的目录中添加“C:\Program Files\nodejs”或更多内容
相关问题