npm安装报错解决合集(一)

2023-05-16

在新版nodejs已经集成了npm,所以npm也都安装好了。可以通过输入下面命令来测试是否成功安装

node -v


npm -v

如果安装成功,都会出现版本号
用npm -v测试,报错:

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'D:lcbsoftware
odejs
ode_modules
pmin
pm-cli.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'D:lcbsoftware
odejs
ode_modules
pmin
pm-cli.js'
[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)[39m
[90m    at Function.Module._load (node:internal/modules/cjs/loader:778:27)[39m
[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)[39m
[90m    at node:internal/main/run_main_module:17:47[39m {
  code: [32m'MODULE_NOT_FOUND'[39m,
  requireStack: []
}

解决办法:

1.卸载重装

2.以管理员方式运行

在这里插入图片描述

配好npm之后,在项目中报错,

输入安装依赖命令

npm install

报错如下:

npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:Program Files
odejs
ode_cache_cacache	mpcc62b2b3
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/@riophae%2fvue-treeselect: EPERM: operation not permitted, open 'C:Program Files
odejs
ode_ca
che_cacache	mpcc62b2b3'
npm ERR!     at C:Program Files
odejs
ode_modules
pm
ode_modulesminipass-fetchlibody.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarboristuild-ideal-tree.js:1061:19)
npm ERR!     at async Arborist.[buildDepStep] (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarboristuild-ideal-tree.js:930:11)
npm ERR!     at async Arborist.buildIdealTree (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarboristuild-ideal-tree.js:216:7)
npm ERR!     at async Promise.all (index 1)
npm ERR!     at async Arborist.reify (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarborist
eify.js:149:5)
npm ERR!     at async Install.install (C:Program Files
odejs
ode_modules
pmlibinstall.js:170:5)
npm ERR!  FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/@riophae%2fvue-treeselect: EPERM: operation not permitted, open 'C:Program Files
odejs
ode_c
ache_cacache	mpcc62b2b3'
npm ERR!     at C:Program Files
odejs
ode_modules
pm
ode_modulesminipass-fetchlibody.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarboristuild-ideal-tree.js:1061:19)
npm ERR!     at async Arborist.[buildDepStep] (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarboristuild-ideal-tree.js:930:11)
npm ERR!     at async Arborist.buildIdealTree (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarboristuild-ideal-tree.js:216:7)
npm ERR!     at async Promise.all (index 1)
npm ERR!     at async Arborist.reify (C:Program Files
odejs
ode_modules
pm
ode_modules@npmcliarboristlibarborist
eify.js:149:5)
npm ERR!     at async Install.install (C:Program Files
odejs
ode_modules
pmlibinstall.js:170:5) {
npm ERR!   code: 'EPERM',
npm ERR!   errno: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'C:\Program Files

odejs
ode_cache_cacache\tmp\cc62b2b3’,
npm ERR! type: ‘system’,
npm ERR! requiredBy: ‘.’
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It’s possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

解决办法:

删除npmrc文件,需要注意的是:不是nodejs安装目录npm模块下的那个npmrc文件,而是在C:Users{账户}下的.npmrc文件.

继续安装依赖:

npm install

出现下面结果:

npm WARN ERESOLVE overriding peer dependency
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated microargs@1.1.2: This project has been renamed to @pawelgalazka/cli-args. Install using @pawelgalazka/cli-args instead
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.de
v/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated microcli@1.3.3: This project has been renamed to @pawelgalazka/cli . Install using @pawelgalazka/cli instead
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated runjs@4.4.2: This project has been renamed to 'tasksfile'. Install using 'npm install tasksfile' instead.
npm WARN deprecated highlight.js@9.18.5: Support has ended for 9.x series. Upgrade to @latest
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated core-js@2.6.12: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old
 core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated html-webpack-plugin@3.2.0: 3.x is no longer supported
npm WARN deprecated eslint-loader@2.2.1: This loader has been deprecated. Please use eslint-webpack-plugin
npm WARN deprecated html-webpack-plugin@3.2.0: 3.x is no longer supported

added 1568 packages, and audited 1569 packages in 3m

105 packages are looking for funding
  run `npm fund` for details

37 vulnerabilities (23 moderate, 11 high, 3 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
npm notice
npm notice New minor version of npm available! 8.1.2 -> 8.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.3.0
npm notice Run npm install -g npm@8.3.0 to update!
npm notice

原因:默认的安装源是国外网站,国内访问不了无法获取依赖包信息。

解决办法:添加

npm config set registry http://registry.npm.taobao.org/

其他常见命令:

# 查看自己的安装源
npm config get registry

# 更换npm源为国内淘宝镜像
npm config set registry http://registry.npm.taobao.org/

# 或者更换为国内npm官方镜像
npm config set registry http://registry.cnpmjs.org/

# 还原npm源
npm config set registry https://registry.npmjs.org/

继续执行:

npm install

结果如下:

up to date in 2s

105 packages are looking for funding
  run `npm fund` for details

即安装完成。

npm启动项目命令

npm run dev
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

npm安装报错解决合集(一) 的相关文章

随机推荐

  • 无人机导航中的各类坐标系

    无人机中的各类坐标系学习笔记 xff1a 北东地坐标系 NED north east down 东北天 ENU east north up 机体坐标系 body frame 1 导航中的坐标系理解 重要参考 导航中 xff0c 最重要的两个
  • 有了Systick中断为什么还要PendSV中断?

    文章目录 问题 xff1a 原因 xff1a 1 在SysTick中断里完成任务切换会降低操作系统的实时性 xff1a 2 把systick优先级设置为最高把PendSV设置为最低的好处 xff1a 3 结语 xff1a 问题 xff1a
  • OpenCV/caffe安装流程

    公司正在做人脸识别系统 xff0c 用到了OpenCV库 xff0c 下面就是根据网上资料以及自己多次部署安装的经验整理的安装流程 xff0c 希望能给一些人一点参考 系统 xff1a Ubuntu1604 CPU架构 xff1a 一般是x
  • win10远程桌面连接ubuntu18.04

    一开始 xff0c 我是根据这个教程进行操作的 xff0c 改了设置为共享 xff0c 安装xrdp等 xff0c 一切都完成后 xff0c 当进行连接时 xff0c 也会出现那个xrdp连接界面 xff0c 但只要一登陆 xff0c 界面
  • 机器学习算法知识点整理

    1生成模型generative model和判别模型 discriminative model 已知输入变量x xff0c 生成模型通过对观测值和标注数据计算联合概率分布P x y 来达到判定估算y的目的 判别模型通过求解条件概率分布P y
  • 我的2014年总结——奔波的一年

    2014年 xff0c 发生了一些人生的大事 xff0c 这些事既有忧 xff0c 又有喜 这因为有这些事情的发生 xff0c 所以我们才越发成熟 xff0c 越发稳重 2014年技术的提升没有前2年那么突飞猛进了 xff0c 生活的事情也
  • 谈谈你对Spring Bean生命周期的理解【面试】

    前言 面试中经常会被问到Spring Bean的生命周期 xff0c 有些人说记不住 xff0c 看了一遍源码也是云里雾里的 xff0c 那是因为只看理论 xff0c 没有自己实践 xff0c 如果自己亲自写代码验证一下 xff0c 不管是
  • FreeRTOS初级篇----名称规范

    数据类型 TickType t xff1a FreeRTOS中断计数值类型 xff0c 可以是16位也可以是32位 xff0c 对于32位CPU来说TickType t最好为32位 BaseType t xff1a 是能够让CPU运行效率最
  • FreeRTOS初级篇----创建任务--动态创建、静态创建

    任务创建函数 xff1a xTaskCreate BaseType t span class token function xTaskCreate span span class token punctuation span TaskFun
  • Linux 性能测试与分析

    源自 http blog sina com cn s blog 71ad0d3f01019uzl html Linux 性能测试与分析 Revision History Version Date Author Description 1 0
  • HashMap底层原理

    文章目录 1 HashMap的概念2 底层数据结构2 JDK1 8之前存在的问题 xff1f 3 问题 xff1a 加载因子为什么默认值为0 75f xff1f 4 问题 xff1a 如果得到key的hash值 xff08 哈希码 xff0
  • 解决虚拟机能够ping通本机,但是无法上网问题

    查看centos网关是否设置正确 root 64 localhost ethan grep GATEWAY etc sysconfig network scripts ifcfg etc sysconfig network scripts
  • c语言字符串分割函数

    C语言字符串分割 strsep函数用于分解字符串为一组字符串 定义语句为char strsep char stringp const char delim 使用实例 xff1a include lt stdio h gt include l
  • Android Socket学习(三)三方apk执行shell命令

    include lt stdio h gt include lt stdlib h gt include lt string h gt include lt fcntl h gt include lt sys types h gt incl
  • ADB命令用法大全

    一 ADB简介 Android Debug Bridge xff0c 安卓调试桥 xff0c 它借助adb exe xff08 Android SDK安装目录platform tools下 xff09 xff0c 用于电脑端与模拟器或者真实
  • SDN入门_基本概念掌握

    部署SDA的链接 xff1a https www cisco com c en us solutions enterprise networks software defined access compatibility matrix ht
  • docker-io, docker-ce, docker-ee 区别

    docker io docker engin 是以前早期的版本 xff0c 版本号是 1 xff0c 默认centos7 安装的是docker io xff0c 最新版是 1 13 docker ce 是社区版本 xff0c 适用于刚刚开始
  • Typora免费版下载【Mac、Windows】

    前言 Typora1 0版本之后是付费版本 xff0c 1 0之前的版本官方网站已移除 xff0c 在网上找了好久 xff0c 现在记录下来 下载 付费版 Typora支持macOS Window Linux系统 xff1a 官方下载地址
  • docker修改镜像名称以及tag版本

    docker tag 镜像ID 镜像名称 tag版本信息 docker tag 8ef375298394 mysql v5 7
  • npm安装报错解决合集(一)

    在新版nodejs已经集成了npm xff0c 所以npm也都安装好了 可以通过输入下面命令来测试是否成功安装 node v npm v 如果安装成功 xff0c 都会出现版本号 用npm v测试 xff0c 报错 xff1a node i