10 examples of 'cannot find module ejs' in JavaScript

Every line of 'cannot find module ejs' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
91function findModule(name) {
92 var result = '';
93 try {
94 result = nodeResolve.sync(name, { basedir: process.cwd() });
95 } catch(e) {
96 try {
97 result = nodeResolve.sync(name, { basedir: __dirname });
98 } catch(e) {
99 console.error('Cannot find module ' + name + ' from ' + process.cwd() + ' or ' + __dirname);
100 throw e;
101 }
102 }
103 return result;
104}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

1function depJs(path) {
2 return require(`../src/js/${path}`);
3}
25function transpileEsModules(code, filename) {
26 const RE = /\b(import|export)\b/
27 if (!RE.test(code)) {
28 return code
29 }
30 // Use babel-preset-env to transpile potentional `import/export` statements
31 return require('@babel/core').transform(code, {
32 filename,
33 babelrc: false,
34 configFile: false,
35 presets: [
36 [
37 require.resolve('@babel/preset-env'),
38 {
39 targets: {
40 node: 'current'
41 }
42 }
43 ]
44 ]
45 }).code
46}
27function getModule(filename, root, source = '') {
28 if (!filename) { return; }
29 return globSync(`**/${ filename }`, {
30 cwd: join(root, source)
31 })[ 0 ];
32}
39export function tryRequire(module, paths = []) {
40 try {
41 let moduleName = module;
42 if (paths.length > 0) moduleName = require.resolve(moduleName, { paths });
43 return require(moduleName); // eslint-disable-line global-require
44 } catch (e) {
45 return null;
46 }
47}
25resolveModule(name)
26{
27 let module = require('./' + name);
28 return module;
29}
178function getModulePath(mod) {
179 return modulePathMap[mod] || `core-js/modules/${mod}`;
180}
22function loadModule(name) {
23 const moduleDir = path.join(__dirname, name);
24 modules[name] = require(moduleDir); // eslint-disable-line global-require
25}
94_loadJsModule(id) {
95 var modulePath = this._modulePath;
96 var version = JSON.parse(fs.readFileSync(modulePath + '/package.json').toString('utf8'))['thingpedia-version'];
97 if (version !== this._manifest.version) {
98 console.log('Cached module ' + this.id + ' is out of date');
99 return null;
100 }
101
102 var deviceClass = require(modulePath);
103 deviceClass.require = function(subpath) {
104 return require(path.resolve(modulePath, subpath));
105 };
106 this._completeLoading(deviceClass);
107
108 const subdevices = deviceClass.subdevices || {};
109 return Promise.all((this.manifest.child_types || []).map((childId) => {
110 if (!(childId in subdevices)) {
111 console.error(`Child device ${childId} is not declared in ${deviceClass.name}.subdevices, this will cause unexpected behavior`);
112 return Promise.resolve();
113 }
114
115 return this._loader.loadManifest(childId, true).then((childManifest) => {
116 const submodule = this.createSubmodule(childId, childManifest, subdevices[childId]);
117 this._loader.injectModule(childId, submodule);
118 });
119 })).then(() => {
120 this._loading = deviceClass;
121 return deviceClass;
122 });
123}
22resolveModule(path: string) {
23 const value = this.zMap[path];
24 if (!value) {
25 throw new Error("can't resolve " + path);
26 }
27 return value;
28}

Related snippets