I'm running into an error when installing redoc (v2.0.0-rc.19 and v2.0.0-rc.27). It seems to have started today after a successful build yesterday.
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.
Here's the most simple Dockerfile which reproduces this. I'm trying to redoc-cli bundle a spec to serve with nginx as part of a larger static website. I have also tried with images between node:10-buster through node:14-buster along with node:13-alpine.
I have also tried to chmod and chown the npm directory, but npm installs anyway.
FROM node:14-buster
RUN npm --version
RUN npm install -g --save redoc-cli
Here's the output I'm getting.
Sending build context to Docker daemon 120.1MB
Step 1/16 : FROM node:14-buster
14-buster: Pulling from library/node
Digest: sha256:b365dc772f6a80863e1cad666d1d4bbc1a031023036a8b9b3859aaffe00a45a7
Status: Image is up to date for node:14-buster
---> da2959f451c5
Step 2/16 : RUN npm --version
---> Using cache
---> 9add407f28da
Step 3/16 : RUN npm install -g --save redoc-cli
---> Running in 01526e8279bc
npm WARN deprecated [email protected]: This is NOT the correct nvm. Visit http://nvm.sh and use the curl command to install it.
> [email protected] preinstall /usr/local/lib/node_modules/redoc-cli/node_modules/node
> node installArchSpecificPackage
npm ERR! code EACCES
npm ERR! syscall scandir
npm ERR! path /root/.npm/_logs
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 65534:0 "/root/.npm"
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /root/.npm/_cacache/index-v5/14/d7/ea219c5ebc10fb0a36ef7e8846ddffeccbde34792bd22566ab58fbd91ac7
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 65534:0 "/root/.npm"
internal/modules/cjs/loader.js:1017
throw err;
^
Error: Cannot find module 'node-linux-x64/package.json'
Require stack:
- /usr/local/lib/node_modules/redoc-cli/node_modules/node/installArchSpecificPackage.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1014:15)
at Function.resolve (internal/modules/cjs/helpers.js:78:19)
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/redoc-cli/node_modules/node-bin-setup/index.js:18:27)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1051:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/redoc-cli/node_modules/node/installArchSpecificPackage.js'
]
}
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/redoc-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] preinstall: `node installArchSpecificPackage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-04-22T20_14_33_175Z-debug.log
The command '/bin/sh -c npm install -g --save redoc-cli' returned a non-zero code: 1
make: *** [build-api] Error 1
I'm available to test alternative configs or further debug, but I'm not sure how to get around this.
I'm experiencing a similar problem, however I'm using pnpm and the errors I get are slightly different, I'll share my findings however.
Today, [email protected] got released, which has node@13 as a dependency. Everything works fine if I add [email protected] to my dependencies. Could you check if that fixes it for you?
Sweet, that seems to work for me!
FROM node:14-buster
RUN npm --version
RUN npm install -g --save [email protected] redoc-cli
[email protected] has been released which fixes this
@adamaltman thanks for the info. Closing this.
Most helpful comment
Sweet, that seems to work for me!