简体   繁体   中英

npm install error and unable to change ownership of root owned files

I'm having trouble to run npm install , because /home/lab/.npm has the root owned files. The problem is I am unable to run sudo chown -R lab:laball "/home/lab/.npm" inside the container. However, after I exited from the container, I already ran sudo chown -R lab:laball "/home/lab/.npm" , but I am unable to see the directories that I saw inside the container (eg _cacache, _locks). Any ideas how to resolve this issue? Thanks!!

npm install error:

I have no name!@cbc1d08db018:/app$ npm install
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /home/lab/.npm/_cacache/tmp/1f88540d
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R lab:laball "/home/lab/.npm"

Inside the container with root owned files in /home/lab/.npm:

I have no name!@cbc1d08db018:~/.npm$ ls -l
total 16
drwxr-xr-x 5 root root 4096 Aug 14 18:54 _cacache
drwxr-xr-x 2 root root 4096 Aug 14 19:38 _locks
drwxr-xr-x 2 root root 4096 Aug 14 19:40 _logs
-rw-r--r-- 1 root root  171 Aug 14 19:38 anonymous-cli-metrics.json

/home/lab/.npm/_logs:

I have no name!@f8b41f2ab2e8:~/.npm/_logs$ ls -l
total 32
-rw-r--r-- 1 root root 1669 Aug 14 18:58 2020-08-14T18_58_53_223Z-debug.log
-rw-r--r-- 1 root root 1669 Aug 14 19:03 2020-08-14T19_03_25_793Z-debug.log
-rw-r--r-- 1 root root 1669 Aug 14 19:04 2020-08-14T19_04_54_260Z-debug.log
-rw-r--r-- 1 root root 1669 Aug 14 19:21 2020-08-14T19_21_50_439Z-debug.log
-rw-r--r-- 1 root root 1669 Aug 14 19:28 2020-08-14T19_28_06_425Z-debug.log
-rw-r--r-- 1 root root 1669 Aug 14 19:32 2020-08-14T19_32_32_753Z-debug.log
-rw-r--r-- 1 root root 1669 Aug 14 19:40 2020-08-14T19_40_09_432Z-debug.log
-rw-r--r-- 1 root root 1669 Aug 14 19:40 2020-08-14T19_40_44_646Z-debug.log
I have no name!@f8b41f2ab2e8:~/.npm/_logs$ cat 2020-08-14T19_40_44_646Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'dev' ]
2 info using npm@6.14.4
3 info using node@v14.2.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle app@1.0.0~predev: app@1.0.0
6 info lifecycle app@1.0.0~dev: app@1.0.0
7 verbose lifecycle app@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle app@1.0.0~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/app/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle app@1.0.0~dev: CWD: /app
10 silly lifecycle app@1.0.0~dev: Args: [ '-c', 'next' ]
11 info lifecycle app@1.0.0~dev: Failed to exec dev script
12 verbose stack Error: app@1.0.0 dev: `next`
12 verbose stack spawn ENOENT
12 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack     at ChildProcess.emit (events.js:315:20)
12 verbose stack     at maybeClose (internal/child_process.js:1051:16)
12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
13 verbose pkgid app@1.0.0
14 verbose cwd /app
15 verbose Linux 4.15.0-112-generic
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
17 verbose node v14.2.0
18 verbose npm  v6.14.4
19 error code ELIFECYCLE
20 error syscall spawn
21 error file sh
22 error errno ENOENT
23 error app@1.0.0 dev: `next`
23 error spawn ENOENT
24 error Failed at the app@1.0.0 dev script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

FYI, you can have a look at the logs in the current directory. And the other way is to remove the _locks folder, and try again to run 'npm install'. If it's not working, please share the logs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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