Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Cannot find module node_modules/get-package-type/index (in nyc module) #488

Closed
anark opened this issue Oct 15, 2020 · 5 comments
Closed

Comments

@anark
Copy link

anark commented Oct 15, 2020

When I try to use the babelrc plugin in cypress

const preprocessor = require('cypress-react-unit-test/plugins/babelrc')

module.exports = (on, config) => {
  preprocessor(on, config)
  // IMPORTANT to return the config object
  // with the any changed environment variables
  return config
  // `on` is used to hook into various events Cypress emits
  // `config` is the resolved Cypress config
}

I get the error

**Message:** The function exported by the plugins file threw an error.

We invoked the function exported by `/Users/home/Development/project/cypress/plugins/index.js`, but it threw an error.

**Details:** Error: Cannot find module '/Users/home/Development/project/node_modules/get-package-type/index'
Require stack:
- /Users/home/Development/project/node_modules/nyc/index.js
- /Users/home/Development/project/node_modules/@cypress/code-coverage/task.js
- /Users/home/Development/project/node_modules/cypress-react-unit-test/plugins/babelrc/index.js
- /Users/home/Development/project/cypress/plugins/index.js
- /Users/home/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js
- /Users/home/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:15)
    at Function.Module._resolveFilename (/Users/home/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/tsconfig-paths/lib/register.js:71:48)
    at Module._load (internal/modules/cjs/loader.js:844:27)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/Users/home/Development/project/node_modules/nyc/index.js:23:24)
    at Module._compile (internal/modules/cjs/loader.js:1145:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
    at Module.load (internal/modules/cjs/loader.js:981:32)
    at Module._load (internal/modules/cjs/loader.js:881:14)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/Users/home/Development/project/node_modules/@cypress/code-coverage/task.js:15:13)
    at Module._compile (internal/modules/cjs/loader.js:1145:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
    at Module.load (internal/modules/cjs/loader.js:981:32)
    at Module._load (internal/modules/cjs/loader.js:881:14)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Module.require (internal/modules/cjs/loader.js:1023:19)
    at require (internal/modules/cjs/helpers.js:77:18)

**Stack trace:**
``
Error: The function exported by the plugins file threw an error.

We invoked the function exported by `/Users/home/Development/project/cypress/plugins/index.js`, but it threw an error.
    at Object.get (/Users/home/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:968:15)
    at EventEmitter.<anonymous> (/Users/home/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/index.js:144:21)
    at EventEmitter.emit (events.js:310:20)
    at ChildProcess.<anonymous> (/Users/home/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:19:22)
    at ChildProcess.emit (events.js:310:20)
    at emit (internal/child_process.js:876:12)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)

``

I get the same issue when adding the webpack loader via

    module.exports = (on, config) => {
      require('cypress-react-unit-test/plugins/load-webpack')(on, config)

       return config
    }
@anark
Copy link
Author

anark commented Oct 15, 2020

It looks like the issue is that I have not setup code coverage. Is it a requirement to setup code coverage to use the webpack or babel loader?

@bahmutov
Copy link
Contributor

This is weird, I will keep this open, but this is nyc not loading correctly, I have released [email protected] to only load nyc when needed, thus if you disable code coverage, then at least it does not crash

@anark
Copy link
Author

anark commented Oct 17, 2020

Very strange, that seems to fix the first issue, however it still shows TypeError: (0 , _schemaUtils.validate) is not a function if you try to run the test.

I've updated cypres-react-unit-test in the example app to show that error if you try to run the spec.

@bahmutov
Copy link
Contributor

@bahmutov bahmutov changed the title Cannot find module node_modules/get-package-type/index Cannot find module node_modules/get-package-type/index (in nyc module) Oct 17, 2020
@anark
Copy link
Author

anark commented Oct 19, 2020

That fixes the terser issue.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants