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

Cannot find module 'tslib' on fresh installation #8162

Closed
alexwhin opened this issue Aug 3, 2020 · 16 comments
Closed

Cannot find module 'tslib' on fresh installation #8162

alexwhin opened this issue Aug 3, 2020 · 16 comments

Comments

@alexwhin
Copy link

alexwhin commented Aug 3, 2020

Current behavior:

On a fresh install and launch (yarn run cypress open) I am receiving the following:

Message: Cannot find module 'tslib'
Require stack:
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/reporter/lib/resolve-dist.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/controllers/reporter.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/routes.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/server.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/project.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/gui/events.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/interactive.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/index.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/cypress.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/index.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/index.js
- 

Stack trace:
Error: Cannot find module 'tslib'
Require stack:
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/reporter/lib/resolve-dist.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/controllers/reporter.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/routes.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/server.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/project.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/gui/events.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/interactive.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/index.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/cypress.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/index.js
- /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/index.js
- 
    at Module._resolveFilename (internal/modules/cjs/loader.js:798:15)
    at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (electron/js2c/browser_init.js:7632:16)
    at Module._load (internal/modules/cjs/loader.js:691:27)
    at Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/override_require.js:18:25)
    at Module.require (internal/modules/cjs/loader.js:853:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/reporter/lib/resolve-dist.js:2:15)
    at Module._compile (internal/modules/cjs/loader.js:968:30)
    at Module.m._compile (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:536:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:986:10)
    at Object.require.extensions.<computed> [as .js] (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:539:12)
    at Module.load (internal/modules/cjs/loader.js:816:32)
    at Module._load (internal/modules/cjs/loader.js:728:14)
    at Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/override_require.js:18:25)
    at Module.require (internal/modules/cjs/loader.js:853:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/controllers/reporter.js:2:18)
    at Module._compile (internal/modules/cjs/loader.js:968:30)
    at Module.m._compile (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:536:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:986:10)
    at Object.require.extensions.<computed> [as .js] (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:539:12)
    at Module.load (internal/modules/cjs/loader.js:816:32)
    at Module._load (internal/modules/cjs/loader.js:728:14)
    at Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/override_require.js:18:25)
    at Module.require (internal/modules/cjs/loader.js:853:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/routes.js:9:18)
    at Module._compile (internal/modules/cjs/loader.js:968:30)
    at Module.m._compile (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:536:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:986:10)
    at Object.require.extensions.<computed> [as .js] (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/ts-node/src/index.ts:539:12)
    at Module.load (internal/modules/cjs/loader.js:816:32)
    at Module._load (internal/modules/cjs/loader.js:728:14)
    at Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/override_require.js:18:25)
    at Module.require (internal/modules/cjs/loader.js:853:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Server.createRoutes (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/server.js:174:12)
    at /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/server.js:220:12
    at tryCatcher (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at Server.open (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/server.js:195:23)
    at /Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/lib/project.js:135:26
    at tryCatcher (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/Alex/Library/Caches/Cypress/4.11.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:439:21)

image

Desired behavior:

I expected to be met with the Cypress test runner.

Test code to reproduce

yarn add cypress
yarn run cypress open

Versions

Cypress 4.11.0
macOS Catalina 10.15.5 Beta

@jennifer-shehane
Copy link
Member

I'm not able to reproduce this from the instructions given.

Can you provide a repo of code that reproduces this issue? Do you have any specific code in cypress folders / cypress.json, tsconfig, other dependencies in your project for example? Did you start from some cli framework to add cypress tests? Node.js version / yarn version?

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Aug 4, 2020
@alexwhin alexwhin closed this as completed Aug 4, 2020
@alexwhin alexwhin reopened this Aug 4, 2020
@hetunandu
Copy link

hetunandu commented Aug 4, 2020

Faced this issue as well. I had some issues with some modules so i did a fresh yarn install after deleting the yarn.lock and node_modules.

PR link
Github Actions failed run

@alexbainter
Copy link

I ran into this issue in a TypeScript project and it was due to #7503, which will apparently be resolved in v5. For now, I switched to v4.3 which doesn't have this problem.

@shaharkazaz
Copy link

shaharkazaz commented Aug 17, 2020

@jennifer-shehane I created a new nx workspace and ran into this issue as well. nothing special done.
as metalex9 mentioned v4.3 is working.

@jennifer-shehane
Copy link
Member

Yeah, 5.0 should have some typescript improvements coming up, so this may be resolved there.

@shaharkazaz
Copy link

@jennifer-shehane Thanks for the quick response, do you happen to know what's the estimated release date on v5? so I'll know when to re-check this

@jennifer-shehane
Copy link
Member

@shaharkazaz We are in the middle of releasing and blocked on this issue atm #8299 So whenever that is resolved.

@stevensacks
Copy link

stevensacks commented Aug 20, 2020

I narrowed it down to this typescript config setting:

importHelpers: true

https://webhint.io/docs/user-guide/hints/hint-typescript-config/import-helpers/

Why is this important?
By enabling the importHelpers compiler option of TypeScript, the compiler will use the tslib package and reduce the size of the output. E.g.:

The docs for it calls out the tslib package by name, so the story checks out.

Now the question is, why would this conflict with Cypress?

You can reliably reproduce this by creating a brand new Create React App with TypeScript, installing Cypress, and then adding importHelpers: true to the tsconfig.json in the root of the project and then run cypress open.

npx create-react-app my-app --template typescript

@alexbainter
Copy link

@stevensacks check out #7503.

Maintainers might want to mark this as duplicate of #7503 and close (👋 @jennifer-shehane)

@jennifer-shehane
Copy link
Member

5.0 was released, so if the above was related to #7503 - this issue should be fixed.

Can anyone confirm if their issue is resolved when updating to 5.0.0?

@cypress-bot cypress-bot bot added stage: awaiting response Potential fix was proposed; awaiting response and removed stage: needs information Not enough info to reproduce the issue labels Aug 21, 2020
@jennifer-shehane
Copy link
Member

Got a repro of this that occurs in both 4.12.1 and 5.0.0 from #8369:

Repro

$ npm install -g @angular/cli
$ ng new my-dream-app
$ cd my-dream-app
$ npm i --save-dev cypress@latest

Edit tsconfig.json to match below:

{
  "compilerOptions": {
    "importHelpers": true,
    "allowJs": true
  },
  "files": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ]
}
$ npx open cypress

Screen Shot 2020-08-21 at 12 02 54 PM

@cypress-bot cypress-bot bot added stage: needs investigating Someone from Cypress needs to look at this and removed stage: awaiting response Potential fix was proposed; awaiting response labels Aug 21, 2020
@stevensacks
Copy link

@jennifer-shehane in my thread that you marked as a duplicate of this one and closed, I mentioned that I was using Cypress 5.

@akashennn
Copy link

Wrong command, try yarn cypress:open

@hetunandu
Copy link

Upgrading cypress to 5.3.0 seemed to solve this for us

@grushetsky
Copy link

Version 5.1.0 stopped emitting this error for us as well.

@jennifer-shehane
Copy link
Member

Closing as resolved.

If you're experiencing a bug similar to this in Cypress, please open a new issue with a fully reproducible example that we can run. There may be a specific edge case with the issue that we need more detail to fix.

@jennifer-shehane jennifer-shehane removed the stage: needs investigating Someone from Cypress needs to look at this label Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants