Skip to content

🐞 tslint-microsoft-contrib missing in dependency chain causing tsline build error when using PNPM (extra work req. for PNPM usage) #2916

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

Closed
1 of 4 tasks
andrewconnell opened this issue Nov 9, 2018 · 15 comments
Labels
area:generator Category: SharePoint Framework Yeoman generator area:spfx Category: SharePoint Framework (not extensions related) status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) type:bug-confirmed Confirmed bug, not working as designed / expected.

Comments

@andrewconnell
Copy link
Collaborator

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

Running pnpm install should get all dependencies so when building the project, it builds with no errors.

Observed Behavior

When you run pnpm install, you don't get the tslint-microsoft-contrib package. To get it, you must run pnpm install --shamefully-flatten. This causes a linting error when building:

> gulp build
...
[12:18:50] Error - [tslint] Failed to load /../tslint.json: Could not find custom rule directory: tslint-microsoft-contrib

Ref: https://pnpm.js.org/docs/en/faq.html#pnpm-does-not-work-with-your-project-here

Steps to Reproduce

  • create a new project with the SPFx Yeoman generator: yo @microsoft/genereator --skip-install

  • run pnpm install

  • run gulp build

  • observe linting error listed above

  • use solution 2 from the PNPM FAQ: run pnpm install --shamefully-flatten

    add --force to rebuild the node_modules folder without having to delete it

  • run gulp build

  • observe no tslinting errors

Confirmed in SPFx v1.7.0

@patmill
Copy link
Contributor

patmill commented Nov 9, 2018

I noticed this yesterday. It looks like an issue with PNPM itself, as the tslint-microsoft-contrib package is listed as a dependency of the @microsoft/sp-tslint-rules package, but it isn't getting pulled down. We'll reach out to Zoltan and see what's going on. He's normally extremely helpful and responsive.

@andrewconnell
Copy link
Collaborator Author

I noticed that too... but couldn't track down the cause. Wonder if it's an issue between a scoped package referencing an unscoped package?

@patmill
Copy link
Contributor

patmill commented Nov 9, 2018

What version of pnpm are you using? I'm on the latest, but I'm going to downgrade to 2.15.1 and see if it still happens. :( still happens. We're digging in further.

@patmill
Copy link
Contributor

patmill commented Nov 10, 2018

OK, we sorted this out. It sounds like (according to @iclanton ) an issue with tslint, where they don't correctly resolve node dependencies. We're looking at submitting a PR to tslint, but in the meantime if you add "tslint-microsoft-contrib": "5.2.1", as a dev dependency, it should work. We'll look at patching the generator to do that manually if the fix to tslint takes a while to prop.

@andrewconnell
Copy link
Collaborator Author

Great find... thanks @patmill !

@wobba
Copy link
Contributor

wobba commented Nov 11, 2018

If I run

yo @microsoft/sharepoint --skip-install
pnpm install
pnpm install tslint-microsoft-contrib@5.2.1 --save-dev
gulp

I now get

[13:53:11] Error - [tslint] { Error: Cannot find module 'tslint'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\repos\Demo1\node_modules\.registry.npmjs.org\tslint-microsoft-contrib\5.2.1\node_modules\tslint-m
crosoft-contrib\noFunctionExpressionRule.js:13:12)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3) code: 'MODULE_NOT_FOUND' }

@patmill Do I still need to use flatten, or is what would the proper order of commands be?

@KingKangMSFT KingKangMSFT added type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. area:generator Category: SharePoint Framework Yeoman generator labels Nov 12, 2018
@patmill
Copy link
Contributor

patmill commented Nov 13, 2018

@wobba - yeah, looks like that suggestion doesn't work. We'll keep digging into this.

@nickpape
Copy link

I filed an issue with pnpm. It does seem to be a pnpm issue. I'll see if I can come up with a workaround.

@nickpape
Copy link

nickpape commented Nov 15, 2018

I'm opening a bug with tslint right now, but for now you can work around this using pnpm's --shamefully-flatten feature.

I.e. run pnpm install --shamefully-flatten.

Until the following issue is fixed: palantir/tslint#4294

You can read more about this flag here: https://pnpm.js.org/docs/en/pnpm-install.html#shamefully-flatten

We found 2 separate issues. The first issue is that tslint is not resolving symlinks correctly. @iclanton has a fix for that he is trying to merge. The second is an unmet peer dependency for tslint-microsoft-contrib on typescript. We plan to fix this issue by updating the dependencies of @microsoft/sp-tslint-rules. Both of those fixes will be included in the next drop of SPFx.

@VesaJuvonen VesaJuvonen added the status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) label Jan 8, 2019
@AJIXuMuK
Copy link
Collaborator

With SPFx 1.8.2 I'm getting

Error - [tslint] { Error: Cannot find module 'typescript'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:/Projects/Tests/pnpm/node_modules/.registry.npmjs.org/tslint/5.9.1/node_modules/tslint/lib/language/walker/blockScopeAwareRuleWalker.js:20:10)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3) code: 'MODULE_NOT_FOUND' }

@wobba
Copy link
Contributor

wobba commented Jun 13, 2019

--shamefully-flatten still work as a workaround

@andrewconnell andrewconnell added type:bug-confirmed Confirmed bug, not working as designed / expected. and removed type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. labels Jun 19, 2019
@deanbot
Copy link
Contributor

deanbot commented Aug 30, 2019

--shamefully-flatten isn't an option with rush however. Adding the packages to each project works with rush.

@VesaJuvonen VesaJuvonen added the area:spfx Category: SharePoint Framework (not extensions related) label Aug 30, 2021
@patmill
Copy link
Contributor

patmill commented Oct 25, 2021

With the latest builds of spfx (1.13.0) and pnpm (6.19.0). I'm not seeing issues any more with the scaffolded code.

@patmill patmill closed this as completed Oct 25, 2021
@wobba
Copy link
Contributor

wobba commented Oct 26, 2021

That's great news @patmill and a good reason to go to 1.13.0. I will upgrade and test myself.

@ghost
Copy link

ghost commented Nov 3, 2021

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:generator Category: SharePoint Framework Yeoman generator area:spfx Category: SharePoint Framework (not extensions related) status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) type:bug-confirmed Confirmed bug, not working as designed / expected.
Projects
None yet
Development

No branches or pull requests

8 participants