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 in file inside "node_modules". E.g. Uncaught Error: Cannot find module './../../config/dev.json' #2977

Closed
XIWEI-house opened this issue Dec 20, 2018 · 3 comments

Comments

@XIWEI-house
Copy link

XIWEI-house commented Dec 20, 2018

Current i am working on using cypress to create AT but i am getting issue when I import internal library which is to create users. The error is thrown from this file

'use strict';

const lodash = require('lodash');
const environment = require('./environment');

let configDir = '../../config';

let env = environment.getEnv() || 'dev';
let envConfig = require(`${configDir}/${env}.json`);
let defaultConfig = require(`${configDir}/default.json`);

function loadConfig() {
  return lodash.merge(defaultConfig, envConfig);
}

module.exports = {
  loadConfig
};

where it is complaining Cannot find module '../../config/dev.json' at line 9. The file is located in the internal module shutterstock-test-user. I confirm the path is right and config folder is on the right directory but still cannot find the module. Is there something wrong with cypress to run with external packages? Thank you!

@brian-mann
Copy link
Member

You didn't post where or how you're using this file, or what your cypress options are or what it is you're trying to do, and we'll need more information such as a reproducible repo in order to investigate this.

It sounds and looks like you're trying to load default configuration which you could/would use our Configuration API which is part of the plugins system.

I'm going to close this issue because there's not enough information provided. If you can provide more and demonstrate how this is happening, we'll open it again.

https://docs.cypress.io/api/plugins/configuration-api.html#Usage

@XIWEI-house
Copy link
Author

@brian-mann Sorry if it is unclear, i am trying to post as much as i can. This is the an internal modularized library so I cannot share repo. The code is from an internal library in node_modules where is using config in npm library. You are right it is not using cypress config but i just want to see if cypress runner can run code in library in node_modules

@bahmutov
Copy link
Contributor

bahmutov commented Dec 21, 2018 via email

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

No branches or pull requests

3 participants