1
resposta

Erro ao instalar dependências com npm devido a um espaço no diretório

Pessoal eu tenho um problema com o meu npm, pois o nome de usuário do computador frequentemente ocorrem erros em instalação de dependências deu uma olhada no stack overflow e me indicaram esse comando:

npm config set cache "C:\Users\Firstname~1\AppData\Roaming\npm-cache" --global

Porém sem sucesso, alguém sabe como posso resolver isso? Também tentei trocar o espaço no nome por %20 que é como o chrome lida com os espaços nos diretórios. Segue o erro na tentativa de instalação, preciso muito de ajuda com isso.

$ yarn eslint:init
yarn run v1.22.4
$ eslint --init
√ How would you like to use ESLint? · style       
√ What type of modules does your project use? · esm
√ Which framework does your project use? · react
√ Does your project use TypeScript? · No / Yes
√ Where does your code run? · browser
√ How would you like to define a style for your project? · guide
√ Which style guide do you want to follow? · airbnb
√ What format do you want your config file to be in? · JavaScript
Checking peerDependencies of eslint-config-airbnb@latest
The config that you've selected requires the following dependencies:

eslint-plugin-react@latest eslint-config-airbnb@latest error@[object Object]
√ Would you like to install them now with npm? · No / Yes
Installing eslint-plugin-react@latest, eslint-config-airbnb@latest, error@[object Object]
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Users\Geraldo~1
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\Geraldo~1'
npm ERR!  [OperationalError: EPERM: operation not permitted, mkdir 'C:\Users\Geraldo~1'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, mkdir 'C:\Users\Geraldo~1'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'mkdir',
npm ERR!     path: 'C:\\Users\\Geraldo~1'
npm ERR!   },
npm ERR!   isOperational: true,
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Users\\Geraldo~1'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Users\Geraldo~1
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\Geraldo~1'
npm ERR!  [OperationalError: EPERM: operation not permitted, mkdir 'C:\Users\Geraldo~1'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, mkdir 'C:\Users\Geraldo~1'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'mkdir',
npm ERR!     path: 'C:\\Users\\Geraldo~1'
npm ERR!   },
npm ERR!   isOperational: true,
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Users\\Geraldo~1'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

Oops! Something went wrong! :(

ESLint: 7.18.0

ESLint couldn't find the plugin "eslint-plugin-react".

(The package "eslint-plugin-react" was not found when loaded as a Node module from the directory "C:\Projetos\imersaoNext\aluraquiz".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm install eslint-plugin-react@latest --save-dev

The plugin "eslint-plugin-react" was referenced from the config file in "BaseConfig".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1 resposta

Tente:

  1. npm cache clean --force
  2. npm install -g npm@latest --force para instalar o NPM como admin
  3. npm cache clean --force

Nunca passei por esse problema pois uso Linux, não sei se resolverá :l