[Bug]PermissionDenied: Reading package.json is not allowed when using npm:[email protected]
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:731:28)
at Module.load (deno:ext/node/02_require.js:630:34)
at Function.Module._load (deno:ext/node/02_require.js:487:14)
at Module.require (deno:ext/node/02_require.js:652:21)
at require (deno:ext/node/02_require.js:782:18)
...
Extra Info
Deno: v1.25.2 macOS: 11.6.8
It appears it only allows reading if it's in the deno_dir node modules. I'm not sure exactly how this should work
i have similar issue with trying to get eslint to work FWIW
("cant" read package.json or .eslintrc.js)
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.
https://github.com/denoland/deno/pull/17134 will be a stepping stone to fix this problem.
Does anyone have a work around?