[BUG] `npm install-scripts approve` saves an absolute path for a local tarball dependency, so the approval breaks on other machines
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, nodejs
- Área
- tooling
Línea de trabajo
Start with the npm install-scripts approve command and the allowScripts keys it writes to package.json, then reproduce with the script in the issue, which copies the project to a new folder and reinstalls. Draft PR #9794 is cited as already changing how these keys are written, so read it first to see what it does. Done means approved local tarball keys are project-relative, like file:../tgzdep-1.0.0.tgz, and both postinstall scripts still run in the moved copy.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
When you approve the install script of a dependency installed from a local tarball, npm install-scripts approve saves the tarball's absolute path as the allowScripts key:
"allowScripts": {
"file:../../dirdep": true,
"file:C:\\Users\\<user>\\work\\tgzdep-1.0.0.tgz": true
}
That key only matches on the machine and in the folder where it was approved. After a clone, on CI, or when the project is moved, the approval no longer applies and the script is blocked again:
npm warn install-scripts 1 package had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts [email protected] (postinstall: ...)
It also commits the approver's local username and folder layout into package.json.
A local directory dependency approved the same way keeps working after the move. Its key (file:../../dirdep) is relative, although it's relative to node_modules rather than to the project, unlike the file:../dirdep spec in dependencies.
Expected Behavior
npm install-scripts approve saves a key relative to the project, like the spec in dependencies (file:../tgzdep-1.0.0.tgz, file:../dirdep), so a committed approval keeps working on every machine.
I checked out draft PR #9794 and ran the same steps with it. It saves file:../dirdep and file:../tgzdep-1.0.0.tgz, and both scripts run in the moved copy. So #9794 appears to fix this, and this issue gives it a user-facing repro.
Steps To Reproduce
mkdir proj dirdep tgzsrc
echo '{"name":"dirdep","version":"1.0.0","scripts":{"postinstall":"node -e \"require(`fs`).writeFileSync(`ran`,``)\""}}' > dirdep/package.json
echo '{"name":"tgzdep","version":"1.0.0","scripts":{"postinstall":"node -e \"require(`fs`).writeFileSync(`ran`,``)\""}}' > tgzsrc/package.json
(cd tgzsrc && npm pack && mv tgzdep-1.0.0.tgz ..)
cd proj && echo '{"name":"proj","version":"1.0.0"}' > package.json
npm install ../dirdep ../tgzdep-1.0.0.tgz
npm install-scripts approve --all
cat package.json # allowScripts has an absolute file:<...>/tgzdep-1.0.0.tgz key
# simulate a teammate's clone: copy the project somewhere else
cd .. && mkdir ../moved && cp -r proj dirdep tgzdep-1.0.0.tgz ../moved/
cd ../moved/proj && rm -rf node_modules && npm install
# -> tgzdep's postinstall is blocked again; dirdep's runs
Environment
- npm: 12.2.3 (
latestbranch) - Node.js: 24.20.0
- OS Name: Windows 11 (the absolute path is
file:C:\\...; on POSIX I'd expectfile:/home/...with the same effect, but I've only tested Windows) - Related: draft PR #9794 changes how these keys are written and fixes this in my test.
- Lenguaje dominante
- JavaScript
- Estrellas
- 10.3k
- Forks
- 5k
- Merge medio
- 4 d 11 h
- PR fusionados (30 d)
- 26
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de npm/cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 2 días
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsPosiblemente ocupada @saruk-vedant la tomó hace 7 días. AbiertoBug Needs Triage Triage Requested
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
npm/cli#10316 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyPosiblemente ocupada @drawliin la tomó hace 42 días. Abiertocmd:delete Priority 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 2 días
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoEngineering Priority 1
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
Los mantenedores suelen responder en 2 días
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysPosiblemente ocupada @greenlincoln05 la tomó hace 63 días. AbiertoPriority 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
npm/cli#10018 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
Issues similares
-
docs: add SECURITY.md vulnerability reporting policyPosiblemente ocupada @AK-Lmn la tomó hoy. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
flisk-sh/linux2wasm#12 ·
Los mantenedores suelen responder en 1 día
-
possible bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Mintplex-Labs/anything-llm#7388 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 60/100
Los mantenedores suelen responder en 1 día
-
v6: Minified bootstrap.min.css is missing header infoPosiblemente ocupada @lazerg la tomó hoy. Abiertobug build confirmed has-pr v6
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
githubnext/gh-aw-workshop#6332 ·
Los mantenedores suelen responder en 1 día