npm install 报错

1、protobufjs@7.4.0 postinstall: node scripts/postinstall verbose stack Error: protobufjs@7.4.0 postinstall: node scripts/postinstall

bash 复制代码
确认是否有postinstall

# node scripts/postinstall

Cannot find module '/home/rio/scripts/postinstall'

解决办法:

bash 复制代码
# 添加忽略参数
npm install @vue/cli -g --ignore-scripts
npm install protobufjs -g --ignore-scripts
npm install --save @opentelemetry/auto-instrumentations-node -g --ignore-scripts

2、ENOENT: no such file or directory, open '/usr/local/package.json'

解决方法:

不能使用在root用户目录部署

到普通用户目录下,执行 npm init ,全默认即可,再执行npm install就正常了

bash 复制代码
[root@rio-accessgate rio]# npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (rio) 
version: (1.0.0) 
description: 
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /home/rio/package.json:

{
  "name": "rio",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes) 
相关推荐
oyzz1204 小时前
Windows 上彻底卸载 Node.js
windows·node.js
小霍同学5 小时前
Node.js 起步指南
node.js
codingWhat5 小时前
用 Express 简单Mock自助终端机读取身份证
node.js·express
回到原点的码农5 小时前
TypeScript 与后端开发Node.js
javascript·typescript·node.js
skiy6 小时前
Webpack、Vite区别知多少?
前端·webpack·node.js
Luna-player6 小时前
npm install vue-awesome-swiper@5.0.1 swiper@7.4.1安装后,我又想全删了,怎么移除
前端·vue.js·npm
橙露20 小时前
Webpack/Vite 打包优化:打包体积减半、速度翻倍
前端·webpack·node.js
十五年专注C++开发1 天前
libuv:一个跨平台的C++异步 I/O 库
开发语言·c++·node.js·libuv·vlibuv
困惑阿三1 天前
客户消息及时反馈
nginx·node.js·飞书·企业微信
饥饿的帕尼尼1 天前
Claude Code本地安装使用教程
node.js·github·claude