Title: Cannot find module X... · Issue #10567 · microsoft/TypeScript · GitHub
Open Graph Title: Cannot find module X... · Issue #10567 · microsoft/TypeScript
X Title: Cannot find module X... · Issue #10567 · microsoft/TypeScript
Description: TypeScript Version: 1.8.0 Code I have two projects. One I'm building general gulp tasks in. One I'm consuming those general gulp tasks. Project 1 contains a class called TasksTools that lives in a file called tasksTools.ts import { exist...
Open Graph Description: TypeScript Version: 1.8.0 Code I have two projects. One I'm building general gulp tasks in. One I'm consuming those general gulp tasks. Project 1 contains a class called TasksTools that lives in a ...
X Description: TypeScript Version: 1.8.0 Code I have two projects. One I'm building general gulp tasks in. One I'm consuming those general gulp tasks. Project 1 contains a class called TasksTools that liv...
Mail addresses
notifications@github.com
reply@reply.github.com
TypeScript@noreply.github.com
kruz79@gmail.com
author@noreply.github.com
Opengraph URL: https://github.com/microsoft/TypeScript/issues/10567
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot find module X...","articleBody":"\u003c!-- BUGS: Please use this template. -->\n\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\n\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\n\n**TypeScript Version:** 1.8.0\n\n**Code**\nI have two projects. One I'm building general gulp tasks in. One I'm consuming those general gulp tasks.\n\nProject 1 contains a class called TasksTools that lives in a file called **tasksTools.ts**\n\n``` ts\nimport { existsSync, lstatSync, readdirSync } from 'fs';\nimport * as gulp from 'gulp';\nimport * as util from 'gulp-util';\nimport * as isstream from 'isstream';\nimport { join } from 'path';\nimport * as tildify from 'tildify';\n\nexport class TasksTools {\n private _gulpConfig: any;\n\n constructor(config: any) {\n this._gulpConfig = config;\n }\n\n /**\n * Loads the tasks within the given path.\n * @param {string} path - The path to load the tasks from.\n * @param {any} config - The configuration file.\n */\n public loadTasksFromDir(path: string, config: any): void {\n this._readDir(path, taskname => this.registerTask(taskname, path, config));\n }\n\n /**\n * Registers the task by the given taskname and path.\n * @param {string} taskname - The name of the task.\n * @param {string} path - The path of the task.\n * @param {any} config - The configuration file.\n */\n public registerTask(taskname: string, path: string, config: any): void {\n const TASK = join(path, taskname);\n gulp.task(taskname, (done: any) => {\n const task = require(TASK);\n if (task.length > 0) {\n return task(config, done);\n }\n\n const taskReturnedValue = task();\n if (isstream(taskReturnedValue)) {\n return taskReturnedValue;\n }\n\n // TODO: add promise handling if needed at some point.\n\n done();\n });\n }\n\n /**\n * Reads the files in the given root directory and executes the given callback per found file.\n * @param {string} root - The root directory to read.\n * @param {function} cb - The callback to execute per found file.\n */\n private _readDir(root: string, cb: (taskname: string) => void): void {\n if (!existsSync(root)) {\n return;\n }\n\n walk(root);\n\n function walk(path: string) {\n let files = readdirSync(path);\n for (let i = 0; i \u003c files.length; i += 1) {\n let file = files[i];\n let curPath = join(path, file);\n if (lstatSync(curPath).isFile() && /\\.ts$/.test(file)) {\n let taskname = file.replace(/\\.ts$/, '');\n cb(taskname);\n }\n else if (lstatSync(curPath).isDirectory()) { // recurse\n walk(curPath);\n }\n }\n }\n }\n}\n```\n\nit also has a definitions file that lives in a file called **index.d.ts**\n\n``` ts\ndeclare module \"@mtm/mtm-ng2-gulp-tasks\" {\nexport class TasksTools {\n public constructor(config: any)\n\n /**\n * Loads the tasks within the given path.\n * @param {string} path - The path to load the tasks from.\n * @param {any} config - The configuration file.\n */\n public loadTasksFromDir(path: string, config: any): void\n\n /**\n * Registers the task by the given taskname and path.\n * @param {string} taskname - The name of the task.\n * @param {string} path - The path of the task.\n * @param {any} config - The configuration file.\n */\n public registerTask(taskname: string, path: string, config: any): void\n }\n}\n```\n\nso I wrap these up and make an NPM library. Then I import that lib into project 2\nHere is my gulp file **gulpfile.ts**\n\n``` ts\nimport * as gulp from 'gulp';\nimport * as config from './gulp.config';\nimport * as runSequence from 'run-sequence';\nimport * as util from 'gulp-util';\n// This line doesn't work\nimport { TasksTools } from '@mtm/mtm-ng2-gulp-tasks';\n\n// If I uncomment this line it works\n//import { TasksTools } from './node_modules/@mtm/mtm-ng2-gulp-tasks/utils/momentum.utils';\n\nlet _gulpConfig = new config.ProjectConfig();\nlet _taskTools = new TasksTools(_gulpConfig);\n\n// Load Default Tasks\n_taskTools.loadTasksFromDir(_gulpConfig.MOMENTUM_TASKS_DIR, _gulpConfig);\n\n// Load Project Tasks\n_taskTools.loadTasksFromDir(_gulpConfig.PROJECT_TASKS_DIR, _gulpConfig);\n```\n\nNow when I try to run this I get the error\n\n**Failed to run \"C:\\TFS\\Dev\\Momentum.Torques\\Client\\Gulp\\mtm-ng2-gulp-tasks\\mtm-ng2-gulp-tasks-test\\Gulpfile.js\"...\ncmd.exe /c gulp --tasks-simple\nmodule.js:442\n throw err;\n ^\nError: Cannot find module '@mtm/mtm-ng2-gulp-tasks'**\n\n**Expected behavior:**\nI expect that this would work\n**Actual behavior:** \nIt did not work\n","author":{"url":"https://github.com/MCKRUZ","@type":"Person","name":"MCKRUZ"},"datePublished":"2016-08-26T19:51:54Z","url":"https://github.com/microsoft/TypeScript/issues/10567"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ae9fe5fb-4ec9-b454-a870-bc169222ee96 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C17E:345E84:477EF4:62D27D:6B049F7E |
| html-safe-nonce | b65ab90ce073d7f8175cc50ce7cf9a81929c1ffc4359098c37ab5d8953e6830b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTdFOjM0NUU4NDo0NzdFRjQ6NjJEMjdEOjZCMDQ5RjdFIiwidmlzaXRvcl9pZCI6IjI4NjIzMzcxNTYxMzgxODA0NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 389999a6ae61a65c789462ce6fcd3dce0bacb43f30d7231a462be8f070a674c0 |
| hovercard-subject-tag | issue:173530271 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/10567/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2a8900b2522df4856b8d571a079ca0a41ed41352a20cb44481d003138e1735fb/microsoft/TypeScript/issues/10567 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2a8900b2522df4856b8d571a079ca0a41ed41352a20cb44481d003138e1735fb/microsoft/TypeScript/issues/10567 |
| og:image:alt | TypeScript Version: 1.8.0 Code I have two projects. One I'm building general gulp tasks in. One I'm consuming those general gulp tasks. Project 1 contains a class called TasksTools that lives in a ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MCKRUZ |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9784b6f42e2d5eac4e394fa88cad134c0dc5b6662b4ff2787a1ed1ef5a96331d |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3fd14143b75b2af7b76bbd23b069867d091adfcc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width