简体   繁体   English

已安装节点但未安装 npm 请帮我修复

[英]node installed but npm is not installed please help me to fix

Problem问题

node -v is working but, node -v 正在工作,但是,
npm -v is not working, error npm -v 不工作,错误


Error encountered遇到错误


C:\Users\HackerGprat>node -v
v19.2.0

C:\Users\HackerGprat>npm -v
node:internal/modules/cjs/loader:1039
  const err = new Error(message);
              ^

Error: Cannot find module '../package.json'
Require stack:
- C:\Users\HackerGprat\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\HackerGprat\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
←[90m    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)←[39m
←[90m    at Module._load (node:internal/modules/cjs/loader:885:27)←[39m
←[90m    at Module.require (node:internal/modules/cjs/loader:1105:19)←[39m
←[90m    at require (node:internal/modules/cjs/helpers:103:18)←[39m
    at createEnginesValidation ←[90m(C:\Users\HackerGprat\←[39mAppData\Roaming\npm\node_modules\←[4mnpm←[24m\lib\cli.js:7:15←[90m)←[39m
    at module.exports ←[90m(C:\Users\HackerGprat\←[39mAppData\Roaming\npm\node_modules\←[4mnpm←[24m\lib\cli.js:73:27←[90m)←[39m
    at Object.<anonymous> ←[90m(C:\Users\HackerGprat\←[39mAppData\Roaming\npm\node_modules\←[4mnpm←[24m\bin\npm-cli.js:2:25←[90m)←[39m
←[90m    at Module._compile (node:internal/modules/cjs/loader:1218:14)←[39m
←[90m    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)←[39m
←[90m    at Module.load (node:internal/modules/cjs/loader:1081:32)←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: [
    ←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
    ←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
  ]
}

Node.js v19.2.0

Try: 1尝试:1

walkthrough installation演练安装

安装 在此处输入图像描述

my doubt is i did not checked ☑ the options of automatic install necessary tools becuase it will take lots of mb so i skiped it.. and by default it was unchecked too [ ]我怀疑我没有检查 ☑自动安装必要工具的选项因为它会占用很多 mb 所以我跳过它..默认情况下它也没有被选中 [ ]

it did not working , and given me error,它没有工作,并给了我错误,


Try: 2尝试:2

it's working on sandbox but not in real pc... i hope you can see which i can't please help它在沙盒上工作,但在真正的电脑上不工作......我希望你能看到我不能提供帮助

在此处输入图像描述


Try: 3尝试:3

tried to copy all installation folder from sandbox to real pc,试图将所有安装文件夹从沙箱复制到真实电脑,

  • node -v -> working节点 -v -> 工作
  • npm -v -> not working , error npm -v ->不工作错误

Try: 4尝试:4

Trying without installing node, copied from sandbox尝试不安装节点,从沙箱复制

  • node -v -> working节点 -v -> 工作
  • npm -v -> not working, error npm -v ->不工作,错误

在此处输入图像描述


Try: 5尝试:5

Tried to change the location with new name NJS试图用新名称NJS更改位置

  • node -v -> working节点 -v -> 工作
  • npm -v -> not working, error npm -v ->不工作,错误

在此处输入图像描述

Try 6: Successfully Installed npm尝试 6:成功安装 npm

as you can see the last line正如你看到的最后一行

  requireStack: [
    ←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
    ←[32m'C:\\Users\\HackerGprat\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
  ]

its pointing to AppData folder,它指向AppData文件夹,
and saying there is npm folder并说有npm文件夹

just delete that npm folder and reinstall the node只需deletenpm folder并重新安装节点

and see it started again working..并看到它再次开始工作..

results结果

在此处输入图像描述

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

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