Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Why is npm run writing into the .npm/_logs directory or creating it? #7032

Closed
2 tasks done
JJ opened this issue Nov 28, 2023 · 1 comment · Fixed by #7033 or GulajavaMinistudio/cli#83
Closed
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x

Comments

@JJ
Copy link
Contributor

JJ commented Nov 28, 2023

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

npm run is creating if it does not exist and writing if it exists into the .npm/_logs directory.

Expected Behavior

Even if logs are turned off completely with the --logs-max=0 option, the directory is still created. This calls for workarounds if the current directory is not writable (a relatively common scenario if you're working inside a container) or workarounds, but there is apparently no way to turn it off completely.

Steps To Reproduce

This Dockerfile:

FROM node:21-alpine

RUN mkdir -p /app/test && chown -R node:node /app && npm install -g npm@latest

USER node

WORKDIR /app

COPY package.json ./

WORKDIR /app/test

ENTRYPOINT ["npm", "--logs-max=0", "run", "test"]

With this package.json

{
  "name": "dotnpm-created",
  "version": "1.0.0",
  "description": "Test file",
  "main": "index.js",
  "scripts": {
    "test": "echo \"test\""
  },
  "author": "",
  "license": "ISC"
}

When run with:

podman run --rm -it -v `pwd`:/app/test -u 1001 jjmerelo/dotnpm-test

It creates a .npm file with:

.npm:
total 12
drwxr-xr-x 3  101000 jmerelo 4096 nov 28 14:38 .
drwxrwxr-x 3 jmerelo jmerelo 4096 nov 28 14:38 ..
drwxr-xr-x 2  101000 jmerelo 4096 nov 28 14:38 _logs

.npm/_logs:
total 8
drwxr-xr-x 2 101000 jmerelo 4096 nov 28 14:38 .
drwxr-xr-x 3 101000 jmerelo 4096 nov 28 14:38 ..

So it still has an empty log directory.

Environment

  • npm@10.2.4
  • node@v21.2.0
  • Alpine OS
  • npm config:
; node bin location = /usr/local/bin/node
; node version = v21.2.0
; npm local prefix = /app
; npm version = 10.2.4
; cwd = /app/test
; HOME = /home/node
@JJ JJ added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Nov 28, 2023
JJ added a commit to JJ/JS-code-examples that referenced this issue Nov 28, 2023
@JJ JJ changed the title [BUG] Why is npm run writing into the .npm/cacache directory? [BUG] Why is npm run writing into the .npm/_logs directory or creating it? Nov 28, 2023
@JJ JJ changed the title [BUG] Why is npm run writing into the .npm/_logs directory or creating it? [BUG] Why is npm run writing into the .npm/_logs directory or creating it? Nov 28, 2023
JJ added a commit to JJ/cli that referenced this issue Nov 28, 2023
After all, it can fail.

This goes mainly to fix npm#7032
@wraithgar
Copy link
Member

silent should not affect the log files at all, that is only a directive to npm on what it sends to stdout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x
Projects
None yet
2 participants