1

I can use the functions of npm normally, but there will always be this warning after each execution result. Is there a way to remove this warning?

$ node -v
v18.0.0

$ npm -v
npm WARN logfile could not be created: Error: EACCES: permission denied, open '/Users/hehe/.npm/_logs/2022-05-02T11_06_01_461Z-debug-0.log'
8.8.0

$ npm install bootstrap
npm WARN logfile could not be created: Error: EACCES: permission denied, open '/Users/hehe/.npm/_logs/2022-05-02T11_15_13_625Z-debug-0.log'

added 2 packages, and audited 4 packages in 2s

2 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

my os: macOS Monterey version 12.0.1

I have try the answers to this question, but is still doesn't work: npm install permission denied (macOS)

Hawk Chou
  • 11
  • 5
  • Does this answer your question? [npm install permission denied (macOS)](https://stackoverflow.com/questions/51967335/npm-install-permission-denied-macos) – Justinas May 02 '22 at 11:14
  • Does this answer your question? [NPM / Error: EACCES: permission denied, scandir](https://stackoverflow.com/questions/70952903/npm-error-eacces-permission-denied-scandir) – LironZ May 02 '22 at 11:29
  • @LironZ No, what I get is a warning, not an error, and doesn't affect normal use. – Hawk Chou May 02 '22 at 11:32
  • @HawkChou, I understand, but there is an error while trying to create a log file, which is not critical for NPM and reported by it as a warning. I think that the underlying issue is the same. – LironZ May 02 '22 at 11:35

2 Answers2

2

I had the same problem and was able to solve it.
I had installed node and npm via brew and suspect that this set the log folder owner to root. This resulted in the problem with the access rights.

I had to correct the access rights for the log folder with the following command (replace USERNAME with your own):

sudo chown -R $USER /Users/USERNAME/.npm/_logs

In your case:

sudo chown -R $USER /Users/hehe/.npm/_logs

I hope my answer helps.

Sp0rTB4cK
  • 21
  • 2
0

the log says that there is no correct access rights for the directory /Users/hehe/.npm/_logs/2022-05-02T11_06_01_461Z-debug-0.log, try:

>  sudo chmod 777 /Users/hehe/.npm/_logs/2022-05-02T11_06_01_461Z-debug-0.log

or, in case it does not fix your issue, try this cmd line:

> sudo chown -R $USER /usr/local/lib/node_modules

More Informations here npm install permission denied (macOS)

Fuzzby
  • 83
  • 1
  • 7
  • still doesn't work – Hawk Chou May 02 '22 at 11:46
  • run `npm cache clean --force` before `npm start` or `npm run start` ? – Fuzzby May 02 '22 at 12:12
  • same as before :( – Hawk Chou May 02 '22 at 13:14
  • have you tried to install `yarn` : `npm install --global yarn` then `yarn --version && yarn start` (`yarn` is a bit better than `npm`) – Fuzzby May 02 '22 at 13:46
  • this guy had the same issues running `npm run build` https://github.com/coreui/coreui-free-bootstrap-admin-template/issues/579, and from what I've red, perhaps Try this: remove node_modules and package-lock.json, remove dist folder, then run: 1.`npm cache clean` 2.`npm install` 3.`npm run start` Hope it helps :) – Fuzzby May 02 '22 at 13:57