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

PNPM and createRequire not working #3867

Closed
David-Else opened this issue Feb 3, 2020 · 4 comments · Fixed by #8840
Closed

PNPM and createRequire not working #3867

David-Else opened this issue Feb 3, 2020 · 4 comments · Fixed by #8840
Labels
bug Something isn't working correctly

Comments

@David-Else
Copy link

I tried to resolve this bug on the glitter channel, and was told it worked fine on other systems that are not using PNPM:

sounds like an edge case with hard links where only one is being followed. npm doesn't use hard links like pnpm as far as I know. Probably worth filing an issue.

So just make a directory with these two files in, have https://github.com/pnpm/pnpm installed and type pnpm install then deno -A rules.ts

rules.ts

import { createRequire } from 'https://deno.land/std@v0.31.0/node/module.ts';
const denoRequire = createRequire(import.meta.url);

const test2 = denoRequire(
  './node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended.js'
);
console.log(JSON.stringify(test2));

const test1 = denoRequire(
  './node_modules/eslint-config-airbnb-typescript/base.js'
);
console.log(JSON.stringify(test1));

package.json

{
  "name": "deno-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.18.0",
    "@typescript-eslint/parser": "^2.18.0",
    "eslint": "^6.8.0",
    "eslint-config-airbnb-typescript": "^6.3.1",
    "eslint-plugin-import": "^2.20.1",
    "typescript": "^3.7.5"
  }
}

Error:

deno -A rules.ts 
Compile file:///home/david/Downloads/denobug/rules.ts
{"default":{"overrides":[{"files":["*.ts","*.tsx"],"rules":{"getter-return":"off","no-dupe-args":"off","no-dupe-keys":"off","no-unreachable":"off","valid-typeof":"off","no-const-a
ssign":"off","no-new-symbol":"off","no-this-before-super":"off","no-undef":"off","no-dupe-class-members":"off","no-redeclare":"off"}}]}}
error: Uncaught Error: Cannot find module 'eslint-config-airbnb-base'
Require stack:
- /home/david/Downloads/denobug/node_modules/eslint-config-airbnb-typescript/base.js
- /home/david/Downloads/denobug/rules.ts
► module.ts:255:19

255       const err = new Error(message);
                      ^

    at _resolveFilename (module.ts:255:19)
    at resolve (module.ts:1105:19)
    at <unknown>:2:61
    at _compile (module.ts:151:36)
    at Module._extensions..js (module.ts:1051:10)
    at load (module.ts:130:34)
    at _load (module.ts:392:14)
    at require (module.ts:116:21)
    at require (module.ts:1101:16)
    at rules.ts:9:15

my system:

linux: centos8

deno 0.31.0
v8 8.1.108
typescript 3.7.2
@ry
Copy link
Member

ry commented Feb 3, 2020

Maybe caused by #3852 ? (If so, we can close this one.)

@ry ry added the bug Something isn't working correctly label Feb 3, 2020
@lucacasonato
Copy link
Member

@David-Else Do you still experience this issue?

@David-Else
Copy link
Author

David-Else commented Aug 14, 2020

@lucacasonato This report was a while ago, so I forgot what I was trying to do, but yes it still gives an error. I recreated the test, but am using the latest Deno 1.3 and standard library 0.65.0. The error today is:

$ deno run --unstable -A rules.ts 
Check file:///home/david/Downloads/test-error/rules.ts
{"default":{"overrides":[{"files":["*.ts","*.tsx"],"rules":{"getter-return":"off","no-dupe-args":"off","no-dupe-keys":"off","no-unreachable":"off","valid-typeof":"off","no-const-assign":"off","no-new-symbol":"off","no-this-before-super":"off","no-undef":"off","no-dupe-class-members":"off","no-redeclare":"off"}}]}}
error: Uncaught Error: Cannot find module 'eslint-config-airbnb-base'
Require stack:
- /home/david/Downloads/test-error/node_modules/eslint-config-airbnb-typescript/base.js
- /home/david/Downloads/test-error/rules.ts
      const err = new Error(message) as Error & {
                  ^
    at Function._resolveFilename (module.ts:266:19)
    at resolve (module.ts:1133:19)
    at Array.map (<anonymous>)
    at Object.<anonymous> (file:///home/david/Downloads/test-error/node_modules/eslint-config-airbnb-typescript/base.js:2:61)
    at Module._compile (module.ts:161:36)
    at Object.Module._extensions..js (module.ts:1080:10)
    at Module.load (module.ts:140:34)
    at Function._load (module.ts:406:14)
    at Module.require (module.ts:126:21)
    at require (module.ts:1129:16)

base.js

module.exports = {
  extends: ['eslint-config-airbnb-base', './lib/shared.js'].map(require.resolve),
};
pnpm --version
5.4.3

So it works on your system OK?

@Liamolucko
Copy link
Contributor

I'll try to fix this.

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants