Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm: PermissionDenied: Reading package.json is not allowed when using npm:[email protected] #15845

Closed
char8x opened this issue Sep 10, 2022 · 5 comments · Fixed by #17209
Closed
Labels
bug Something isn't working correctly node compat

Comments

@char8x
Copy link

char8x commented Sep 10, 2022

Problem

Output PermissionDenied when running

deno run --unstable --allow-env --allow-read npm:[email protected] test.js

Simplest Reproduction

Project files like this

test.js

import assert from "assert";
describe("Array", function () {
  describe("#indexOf()", function () {
    it("should return -1 when the value is not present", function () {
      assert.equal([1, 2, 3].indexOf(4), -1);
    });
  });
});

package.json

{
  "type": "module"
}

file permission

drwxr-xr-x   .
drwxr-xr-x   ..
-rw-r--r--   package.json
-rw-r--r--   test.js

Error Output

PermissionDenied: Reading .../mocha-example/package.json is not allowed
    at Object.Module._extensions..js (deno:ext/node/02_require.js:738:28)
    at Module.load (deno:ext/node/02_require.js:636:34)
    at Function.Module._load (deno:ext/node/02_require.js:493:14)
    at Module.require (deno:ext/node/02_require.js:658:21)
    at require (deno:ext/node/02_require.js:792:18)
    ...

Extra Info

Deno: v1.26.2
macOS: 12.6.1

@brenelz
Copy link
Contributor

brenelz commented Sep 11, 2022

It appears it only allows reading if it's in the deno_dir node modules. I'm not sure exactly how this should work

@kitsonk kitsonk added bug Something isn't working correctly node compat labels Sep 11, 2022
@char8x char8x changed the title [Bug]PermissionDenied: Reading package.json is not allowed when using npm:[email protected] npm: PermissionDenied: Reading package.json is not allowed when using npm:[email protected] Sep 15, 2022
@traceypooh
Copy link

i have similar issue with trying to get eslint to work FWIW
("cant" read package.json or .eslintrc.js)

@dsherret dsherret added bug Something isn't working correctly and removed bug Something isn't working correctly labels Dec 20, 2022
@dsherret
Copy link
Member

Can still reproduce in the latest canary. The npm code needs to take user permissions into account instead of being restricted to the cache or node_modules directory.

@bartlomieju
Copy link
Member

#17134 will be a stepping stone to fix this problem.

@arjunyel
Copy link

arjunyel commented Jan 7, 2023

Does anyone have a work around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants