Skip to content

Getting "Cannot find module" when trying to use custom schematics with new command #7744

Closed
@fxck

Description

@fxck

There's little to no info about how to actually use schematics, so I tried forking @schematics/angular, changed couple things, published on npm (https://www.npmjs.com/package/@thescrollbar/schematics / https://github.com/thescrollbar/schematics), did following https://github.com/nrwl/nx/tree/master/packages/schematics#installing-nrwlschematics and tried

ng new impr --collection=@thescrollbar/schematics, which throws error listed below.. in case you are wondering, that path does exist on my filesystem and does link to this https://github.com/thescrollbar/schematics/tree/master/application

I also tried publishing contents of https://github.com/angular/devkit/tree/master/packages/schematics/angular to npm without changing anything and use it as schematics, didn't work either

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.2
node: 8.1.4
os: darwin x64

The log given by the failure.

Error: Cannot find module '/Users/fxck/.yarn-config/global/node_modules/@thescrollbar/schematics/application'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.resolve (internal/module.js:18:19)
    at new ExportStringRef (/Users/fxck/.yarn-config/global/node_modules/@angular-devkit/schematics/tools/export-ref.js:15:32)
    at NodeModulesEngineHost._resolveReferenceString (/Users/fxck/.yarn-config/global/node_modules/@angular-devkit/schematics/tools/node-module-engine-host.js:18:21)
    at NodeModulesEngineHost.createSchematicDescription (/Users/fxck/.yarn-config/global/node_modules/@angular-devkit/schematics/tools/file-system-engine-host-base.js:92:34)
    at SchematicEngine.createSchematic (/Users/fxck/.yarn-config/global/node_modules/@angular-devkit/schematics/src/engine/engine.js:63:40)
    at CollectionImpl.createSchematic (/Users/fxck/.yarn-config/global/node_modules/@angular-devkit/schematics/src/engine/collection.js:11:29)
    at Object.getSchematic (/Users/fxck/.yarn-config/global/node_modules/@angular/cli/utilities/schematics.js:40:23)
    at Class.run (/Users/fxck/.yarn-config/global/node_modules/@angular/cli/tasks/schematic-get-options.js:12:40)
    at Class.beforeRun (/Users/fxck/.yarn-config/global/node_modules/@angular/cli/commands/new.js:99:31)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions