You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> [email protected] server
> node index.js
Server running at http://127.0.0.1:3000/
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /nonexistent
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/nonexistent'
npm ERR! [Error: EACCES: permission denied, mkdir '/nonexistent'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/nonexistent'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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! Log files were not written due to an error writing to the directory: /nonexistent/.npm/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
At this point my server is still running, as a background process. (as if I ran the command with &, but I did not.)
$ curl http://127.0.0.1:3000/
Hello World
I know I can fix the EACCES by making sure the path is writable using sudo -u nobody sh -c 'npm run server --cache .', my problem is that npm does not handle the error in an expected way.
Expected Behavior
I would expect that either
A) The server stops and the process exits with an error code due to the errors being fatal, OR
B) The process runs in the foreground ignoring non-fatal errors.
Steps To Reproduce
// index.jsconsthttp=require('http');consthostname='127.0.0.1';constport=3000;constserver=http.createServer((req,res)=>{res.statusCode=200;res.setHeader('Content-Type','text/plain');res.end('Hello World');});server.listen(port,hostname,()=>{console.log(`Server running at http://${hostname}:${port}/`);});
Now run sudo -u nobody sh -c 'npm run server', where -u nobody causes npm not to be able to write logs.
Environment
npm: 9.6.6
Node.js: v20.2.0
OS Name: Ubuntu 22.04.2 LTS (jammy)
System Model Name: AWS EC2 / also on MacBook Air 2020 with Docker
npm config:
; node bin location = /usr/bin/node; node version = v20.2.0; npm local prefix = /app; npm version = 9.6.6; cwd = /app; HOME = /root; Run `npm config ls -l` to show all defaults.
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When I run this command
$ sudo -u nobody sh -c 'npm run server'
I get the following output:
At this point my server is still running, as a background process. (as if I ran the command with
&
, but I did not.)I know I can fix the EACCES by making sure the path is writable using
sudo -u nobody sh -c 'npm run server --cache .'
, my problem is that npm does not handle the error in an expected way.Expected Behavior
I would expect that either
A) The server stops and the process exits with an error code due to the errors being fatal, OR
B) The process runs in the foreground ignoring non-fatal errors.
Steps To Reproduce
Now run
sudo -u nobody sh -c 'npm run server'
, where-u nobody
causes npm not to be able to write logs.Environment
The text was updated successfully, but these errors were encountered: