欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

排障集锦:九九八十一难之第十六难!-------------enoent ENOENT: no such file or directory, open ‘/root/package.json‘

程序员文章站 2022-05-30 09:47:53
...

npm全称为Node Package Manager,是一个基于Node.js的包管理器

npm install
安装之前,npm install 会先检查,node_modules 目录之中是否已经存在指定模块

报错信息如下

[[email protected] ~]# npm run start &
[1] 58104
[[email protected] ~]# npm ERR! path /root/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/root/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-09-14T13_51_52_203Z-debug.log

[1]+  退出 254              npm run start

查看日志报错信息如下

[[email protected] ~]# cat /root/.npm/_logs/2020-09-14T13_46_01_150Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'start' ]
2 info using npm@5.3.0
3 info using node@v8.2.1
4 verbose config Skipping project config: /root/.npmrc. (matches userconfig)
5 verbose stack Error: ENOENT: no such file or directory, open '/root/package.json'
6 verbose cwd /root
7 verbose Linux 3.10.0-957.el7.x86_64
8 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "start"
9 verbose node v8.2.1
10 verbose npm  v5.3.0
11 error path /root/package.json
12 error code ENOENT
13 error errno -2
14 error syscall open
15 error enoent ENOENT: no such file or directory, open '/root/package.json'
16 error enoent This is related to npm not being able to find a file.
17 verbose exit [ -2, true ]

解决方案

[[email protected] src]# cd elasticsearch-head/   '回到安装nodejs文件下 进行重新初始化'
[[email protected] elasticsearch-head]# npm install
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/karma/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression

重新启动

[[email protected] elasticsearch-head]#  npm run start &
[1] 58150
[[email protected] elasticsearch-head]# 
> elasticsearch-head@0.0.0 start /usr/local/src/elasticsearch-head
> grunt server

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

[[email protected] elasticsearch-head]# netstat -ntap | grep 9100
tcp        0      0 0.0.0.0:9100            0.0.0.0:*               LISTEN      58160/grunt