(generator-polymer) yo polymer fails, cannot find module 'find-index'
Asked Answered
I

3

11

Here is the full error after typing yo polymer in a clean directory.

module.js:338
    throw err;
          ^
Error: Cannot find module 'find-index'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/download/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/index.js:4:17)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

I've just done a reinstall of everything node related, but here are the versions.

node:              v0.12.7
npm:               2.11.3
yo:                1.4.7
bower:             1.4.1
grunt-cli:         v0.1.13
gulp:              3.9.0
generator-polymer: 1.0.5

Note that I get a warning when installing generator-polymer.

npm WARN deprecated [email protected]: the module is now available as 'css-select'
npm WARN deprecated [email protected]: the module is now available as 'css-what'

I have also tried installing the three problematic modules manually, which appeared to be successful.

sudo npm install -g find-index css-select css-what

I'm out of ideas. Node was installed from source downloaded at nodejs.org.

EDIT: I have also installed n using sudo npm install -g n to install node. I have tried uninstalling/reinstalling node/npm with no luck.

EDIT2: yo webapp works, so the culprit is (must be?) generator-polymer.

Investigate answered 3/8, 2015 at 13:33 Comment(4)
My versions match all of yours except that I don't have grunt-cli installed, and my generator-polymer version is 1.0.4. I don't thin that grunt-cli matters because the generated polymer code uses gulp. Note that I had some trouble digging up the generator-polyer version. I got it using the command: "npm ls -g --depth=1 2>/dev/null | grep generator". I suggest you investigate your generator-polymer version.Reinke
My generator-polymer version is actually 1.0.5, as seen in the top line here, pastebin.com/0K27JDpi. That was the output of reinstalling the generator. The last leaf there also shows 0.18.10, but i'll update the post. Do you get warnings for CSSselect and CSSwhat (above)?Investigate
My last comment could be clearer. sudo npm install -g generator-polymer is how checked the version for the original post, but I did not notice 1.0.5 as the version number the first time.Investigate
I don't get any CSSselect of CSSwhat warnings.Reinke
I
0

I was able to fix the issue by deleting the offending directory,

/usr/lib/node_modules/generator-polymer

I do not remember if simply reinstalling generator polymer (sudo npm install -g generator-polymer) fixed the issue completely (let me know and i'll update the answer). I ended up reinstalling everything to make sure any issues were mitigated.

Environment setup

  1. Install node.js. Follow the instructions on their site to install for your OS.
  2. Install Yeoman by typing the command sudo npm install -g yo in your system's console. The -g installs the package globally, which is why the sudo command is needed (your system may vary).
  3. Next we'll install a couple of Yeoman generators.
    1. Install the polymer generator with the command sudo npm install -g generator-polymer.
    2. (optional) Install the polymer element generator with the command sudo npm install -g generator-element. This will help with scaffolding out custom Polymer elements.

Starting a new project

With the development environment setup, starting a project is extremely easy.

mkdir my-project
cd my-project
yo polymer

A new polymer project will be setup in the my-project directory using the latest releases of polymer and other dependencies.

Testing a project

Polymer uses the gulp streaming build system. From your project's directory, simply type

gulp serve

See my Polymer 1.0 Notes Google doc.

Investigate answered 22/1, 2016 at 12:47 Comment(0)
C
0

I see you are installing it to global modules. Did you try to install generator-polymer just for project (it should fix warnings)

You list only root packages version. But problem seems to be in dependencies. Accordign your stack trace it's caused by yeoman-generator / download module

Here is my versions of all depes. Look at this packages and check your version (i have [email protected] and [email protected] which works fine)

[email protected] node_modules/generator-polymer
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

Anyway, I would try install all deps as local modules.

EDIT: you should have this directory in you project

node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/download/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob2base/node_modules/find-index

where in tree glob2base is 0.0.12 glob-stram is 3.1.18 vinyl-fs is 0.3.13 download is 3.3.0 yeoman-generator is 0.18.10

Chavez answered 18/8, 2015 at 8:10 Comment(1)
even when installing everything locally via npm install yo bower gulp generator-polymer I still get an error. pastebin of full output. generator-polymer is now at version 1.1.0. Using only the generator locally (everything else globally) still failed.Investigate
D
0

There is a problem with using npm -g unless you can access it without using sudo (ie you have permission to read/write etc in the place where the global modules are installed).

As far as I can work out its bower that is the culprit

The way round the problem is to run npm config edit, and change the prefix value to something you do have access to without sudo. This edits ~/.npmrc file

You then install globally for you.

Drying answered 25/11, 2015 at 17:36 Comment(0)
I
0

I was able to fix the issue by deleting the offending directory,

/usr/lib/node_modules/generator-polymer

I do not remember if simply reinstalling generator polymer (sudo npm install -g generator-polymer) fixed the issue completely (let me know and i'll update the answer). I ended up reinstalling everything to make sure any issues were mitigated.

Environment setup

  1. Install node.js. Follow the instructions on their site to install for your OS.
  2. Install Yeoman by typing the command sudo npm install -g yo in your system's console. The -g installs the package globally, which is why the sudo command is needed (your system may vary).
  3. Next we'll install a couple of Yeoman generators.
    1. Install the polymer generator with the command sudo npm install -g generator-polymer.
    2. (optional) Install the polymer element generator with the command sudo npm install -g generator-element. This will help with scaffolding out custom Polymer elements.

Starting a new project

With the development environment setup, starting a project is extremely easy.

mkdir my-project
cd my-project
yo polymer

A new polymer project will be setup in the my-project directory using the latest releases of polymer and other dependencies.

Testing a project

Polymer uses the gulp streaming build system. From your project's directory, simply type

gulp serve

See my Polymer 1.0 Notes Google doc.

Investigate answered 22/1, 2016 at 12:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.