El problema:
Recientemente compré el nuevo M2 MacBook Pro e instalé NodeJS pero no puedo instalar ningún paquete en la carpeta del proyecto. Cuando ejecuto el comando "npm install express" obtengo esta salida en Terminal:
npm ERR! code ENOENT
npm ERR! syscall mkdir
npm ERR! path /path-to-tmp
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, mkdir '/path-to-tmp'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Log files were not written due to an error writing to the directory: /path-to-tmp/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
Cuando ejecuto el comando con el –-loglevel-verbose
obtengo este resultado:
npm verb cli /usr/local/bin/node /opt/homebrew/bin/npm
npm info using npm@9.5.1
npm info using node@v19.8.1
npm verb cache could not create cache: Error: ENOENT: no such file or directory, mkdir '/path-to-tmp'
npm verb logfile could not create logs-dir: Error: ENOENT: no such file or directory, mkdir '/path-to-tmp'
npm verb title npm install express
npm verb argv "install" "express" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:/path-to-tmp/_logs/2023-03-25T12_46_53_501Z-
npm verb logfile could not be created: Error: ENOENT: no such file or directory, open '/path-to-tmp/_logs/2023-03-25T12_46_53_501Z-debug-0.log'
npm verb logfile no logfile created
npm verb stack Error: ENOENT: no such file or directory, mkdir '/path-to-tmp'
npm verb cwd /Users/USER_NAME/Desktop/Test
npm verb Darwin 22.3.0
npm verb node v19.8.1
npm verb npm v9.5.1
npm ERR! code ENOENT
npm ERR! syscall mkdir
npm ERR! path /path-to-tmp
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, mkdir '/path-to-tmp'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm verb exit -2
npm verb unfinished npm timer command:install 1679748413521
npm verb unfinished npm timer reify 1679748413523
npm verb unfinished npm timer reify:loadTrees 1679748413543
npm verb unfinished npm timer idealTree 1679748413543
npm verb unfinished npm timer idealTree:buildDeps 1679748413547
npm verb unfinished npm timer idealTree:#root 1679748413547
npm verb code -2
npm ERR! Log files were not written due to an error writing to the directory: /path-to-tmp/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
Correr sólo node install
devuelve la salida normal al terminal y yo había ejecutado npm init
previamente y tengo un archivo package.json en la carpeta del proyecto. Mi directorio activo en terminal era la carpeta del proyecto cuando ejecuté estos comandos.
Sistema operativo y programas:
- MacOS Ventura 13.2.1
- Versión del intérprete de comandos de terminal ZSH: 5.8.1
- Versión del nodo: 19.8.1
- Versión de NPM: 9.5.1
Pasos de depuración que he dado:
- Añadido
.zshrc
y se aseguró de que/usr/local/bin
está en mi$PATH
- Probado con
sudo
en colaboración connpm install
- He intentado crear manualmente el
/path-to-tmp
en la carpeta/
aunque esto falló porque el directorio/
es estrictamente permisos de lectura para todos los usuarios - Se han modificado los permisos de la carpeta "Test" para que todos los usuarios tengan acceso de lectura y escritura.
- Desinstalado y reinstalado Node junto con tratar de utilizar tanto Homebrew y sitio web para instalar con
- Suprimido
package-lock.json
y volví a intentar ejecutarnode install