Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

patternlab init throws an error #28

Closed

Description

@benhalverson

General information

patternlab init throws an error
OSX version 10.10.5

  • NodeJS version: 7.4.0
  • NPM version: 4.0.5

Problem description

After running patternlab init I get the following error:

    if (err) { throw err; }
               ^

Error: ENOENT: no such file or directory, scandir '/Users/benhalverson/projects/pl-test/node_modules'
    at Object.fs.readdirSync (fs.js:871:18)
    at diveSync (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/diveSync/diveSync.js:30:19)
    at findEngineModulesInDirectory (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:37:3)
    at /Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:58:28
    at Array.forEach (native)
    at loadAllEngines (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:57:22)
    at Object.<anonymous> (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:183:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)```


### Reproduction steps
npm i -g pattern-lab/patternlab-node-cli
patternlab init 

Activity

  1. bmuenzenmeyer commented on Feb 2, 2017

    @bmuenzenmeyer
    Member

    First up, thanks for helping us test the CLI. It's important for more 👀 to get on it.

    I did some testing too.

    I cannot even run patternlab -h in a new directory. I would expect that to be able to output the help at least.

    If I cd to a directory that has an edition setup within it, patternlab -h does work. So it seems to me that in both cases of failure, the CLI is expecting some structure to exist... but how much?

    ...

    more testing

    ...

    okay, so I added a node_modules/ directory in the folder I was testing within and now patternlab -h works. Can we add that if not found?

  2. bmuenzenmeyer commented on Feb 2, 2017

    @bmuenzenmeyer
    Member

    and @benhalverson can you try adding node_modules/ and then run init again?

  3. benhalverson commented on Feb 2, 2017

    @benhalverson
    ContributorAuthor

    Heres the new error for patterlab init

    
    
    Loading engines from the edition or test directory...
    
    
    /Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:85
        throw new Error('No engines loaded! Something is seriously wrong.');
        ^
    
    Error: No engines loaded! Something is seriously wrong.
        at loadAllEngines (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:85:11)
        at Object.<anonymous> (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/pattern_engines.js:183:1)
        at Module._compile (module.js:571:32)
        at Object.Module._extensions..js (module.js:580:10)
        at Module.load (module.js:488:32)
        at tryModuleLoad (module.js:447:12)
        at Function.Module._load (module.js:439:3)
        at Module.require (module.js:498:17)
        at require (internal/module.js:20:19)
        at Object.<anonymous> (/Users/benhalverson/.nvm/versions/node/v7.4.0/lib/node_modules/patternlab-node-cli/node_modules/patternlab-node/core/lib/object_factory.js:3:22)```
    
  4. benhalverson commented on Feb 2, 2017

    @benhalverson
    ContributorAuthor

    @bmuenzenmeyer
    Here are the workaround steps

    • npm init to create a package.json
    • npm i -s pattern-lab/patternlab-node-cli
    • patternlab init
  5. bmuenzenmeyer commented on Feb 2, 2017

    @bmuenzenmeyer
    Member

    A ha! thanks for the additional troubleshooting.

    npm i -s pattern-lab/patternlab-node-cli

    Interesting that you have to install the cli locally in order for it to work. My theory with the previous stack trace was that pattern_engines was failing because it could not find the default mustache pattern engine, which was installed along with the cli and core library in your global locations, rather than the current working directory

  6. raphaelokon commented on Feb 2, 2017

    @raphaelokon
    Contributor

    @benhalverson @bmuenzenmeyer Thanks for the report.Can we create a minimal test case for this.

    From what I read is that you install the cli globally and then try to run patternlab init it in a project dir, correct?

  7. self-assigned this
    on Feb 2, 2017
  8. raphaelokon commented on Feb 2, 2017

    @raphaelokon
    Contributor

    Okay, I was able to reproduce the error:

    1. Install cli globally
    2. Create a folder an run patternlab --help
    3. Results in the same engine error from above

    This is a bug.

  9. raphaelokon commented on Feb 2, 2017

    @raphaelokon
    Contributor

    Okay, so far what I get from looking into the issues around global cli is that the core's postinstall isn't run for me after installing the cli.

    When I try to manually run the core's postinstall from the global cli I get:

    → patternlab-node: node core/scripts/postinstall.js 
    Beginning Pattern Lab postinstall...
    No starterkits found to automatically load.
    

    @bmuenzenmeyer any ideas?

  10. bmuenzenmeyer commented on Feb 2, 2017

    @bmuenzenmeyer
    Member

    No engines loaded! Something is seriously wrong

    it's failing because pattern_engines is not looking for potentially globally installed engines. We need to research how to look for globally installed packages. Or does require() just degrade to that?

    ....

    doing some quick research, it seems that expecting modules to be installed globally is not a good idea, and it's best to put your dependencies into the local node_modules/ whenever possible.

    Does this fundamentally change the CLI then, or am I misreading something?

  11. raphaelokon commented on Feb 2, 2017

    @raphaelokon
    Contributor

    doing some quick research, it seems that expecting modules to be installed globally is not a good idea, and it's best to put your dependencies into the local node_modules/ whenever possible.

    What do you refer to by dependencies?

    Does this fundamentally change the CLI then, or am I misreading something?

    I do not think so :-) CLI is should be pretty agnostic for such things.

    it's failing because pattern_engines is not looking for potentially globally installed engines. We need to research how to look for globally installed packages. Or does require() just degrade to that?

    AFAIK require resolves only to your package's local node_modules which is good. Except you pointing NODE_PATH to your global node_modules.

  12. raphaelokon commented on Feb 19, 2017

    @raphaelokon
    Contributor

    Closing as this is a won't fix for global installs until we hit #32

  13. leonardoalemax commented on Feb 14, 2018

    @leonardoalemax

    this should be in readme.md

  14. raphaelokon commented on Feb 14, 2018

    @raphaelokon
    Contributor

    @leualemax You are right. Thanks for pointing it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions