You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2019. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 27, 2019. It is now read-only.
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
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?
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)```
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
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?
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.
Activity
bmuenzenmeyer commentedon Feb 2, 2017
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 -hin a new directory. I would expect that to be able to output the help at least.If I
cdto a directory that has an edition setup within it,patternlab -hdoes 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 nowpatternlab -hworks. Can we add that if not found?bmuenzenmeyer commentedon Feb 2, 2017
and @benhalverson can you try adding
node_modules/and then runinitagain?benhalverson commentedon Feb 2, 2017
Heres the new error for patterlab init
benhalverson commentedon Feb 2, 2017
@bmuenzenmeyer
Here are the workaround steps
bmuenzenmeyer commentedon Feb 2, 2017
A ha! thanks for the additional troubleshooting.
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
raphaelokon commentedon Feb 2, 2017
@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 initit in a project dir, correct?raphaelokon commentedon Feb 2, 2017
Okay, I was able to reproduce the error:
patternlab --helpThis is a bug.
raphaelokon commentedon Feb 2, 2017
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:
@bmuenzenmeyer any ideas?
bmuenzenmeyer commentedon Feb 2, 2017
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?
raphaelokon commentedon Feb 2, 2017
What do you refer to by
dependencies?I do not think so :-) CLI is should be pretty agnostic for such things.
AFAIK
requireresolves only to your package's local node_modules which is good. Except you pointingNODE_PATHto your globalnode_modules.pushing experimental fix for a CLI issue
raphaelokon commentedon Feb 19, 2017
Closing as this is a won't fix for global installs until we hit #32
leonardoalemax commentedon Feb 14, 2018
this should be in readme.md
raphaelokon commentedon Feb 14, 2018
@leualemax You are right. Thanks for pointing it out.