yeoman / generator-polymer

Scaffold out a Polymer project
http://polymer-project.org
926 stars 149 forks source link

Error while creating a new element using yo polymer:el #232

Closed itsashis4u closed 8 years ago

itsashis4u commented 8 years ago
ashish@inspiron:~/projects/polymer-starter-kit-1.1.1$ yo polymer:el new-list
? Would you like to include an import in your elements.html file? ?
Would you like to include an import in your elements.html file? ?
Would you like to include an import in your elements.html file? Yes
? What type of test would you like to create? None
events.js:141
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read property 'replace' of undefined
    at module.exports.yeoman.generators.Base.extend.el (/home/ashish/.nvm/versions/node/v4.1.2/lib/node_modules/generator-polymer/el/index.js:109:14)
    at /home/ashish/.nvm/versions/node/v4.1.2/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:374:17)
ashish@inspiron:~/projects/polymer-starter-kit-1.1.1$ yo --version && echo $PATH $NODE_PATH && node -e 'console.log(process.platform, process.versions)' && cat Gruntfile.js
1.4.8
/home/ashish/.gvm/bin:/home/ashish/.nvm/versions/node/v4.1.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
linux { http_parser: '2.5.0',
  node: '4.1.2',
  v8: '4.5.103.35',
  uv: '1.7.5',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  modules: '46',
  openssl: '1.0.2d' }
cat: Gruntfile.js: No such file or directory
ragingwind commented 8 years ago

Which version of generator-polymer do you use? I couldn't reproduce the issue

SterlingVix commented 8 years ago

I have the same or a similar issue:

aaronmelocik@Vonnegut:/private/var/www/metrodigi/testing/generator-polymer$ yo polymer:element add-name
? Would you like to include an import in your elements.html file? No
? What type of test would you like to create? TDD

events.js:85
      throw er; // Unhandled 'error' event
            ^
AssertionError: Trying to copy from a source that does not exist: /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/element/templates/element.html
    at EditionInterface.exports._copySingle (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:45:3)
    at EditionInterface.exports.copy (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy-tpl.js:16:8)
    at module.exports.yeoman.generators.Base.extend.el (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/el/index.js:100:13)
    at /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:358:17)

My version of generator-polymer is 1.2.3. I'm on OSX, and have generator-angular working just fine. NPM install paths, $PATH, etc. look fine from where I'm standing...

Any more info I can give you to help with this? I'd love to get this up and running.

ragingwind commented 8 years ago

@itsashis4u I can reduce same problem. it was raised when answer Yes.

luxedo commented 8 years ago

I'm having the same issue

john@njohn ~/Projects/l0gical $ yo polymer:el settings-data --docs
? Would you like to include an import in your elements.html file? Yes
? What type of test would you like to create? TDD
events.js:141
      throw er; // Unhandled 'error' event
      ^

TypeError: Cannot read property 'replace' of undefined
    at module.exports.yeoman.generators.Base.extend.el (/usr/lib/node_modules/generator-polymer/el/index.js:109:14)
    at /usr/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:368:17)```

If i chose not to include the import to elements.html then it works

john@njohn ~/Projects/l0gical $ yo polymer:el settings-data --docs
? Would you like to include an import in your elements.html file? No
? What type of test would you like to create? TDD
   create app/elements/settings-data/settings-data.html
   create app/test/settings-data-basic.html
   create app/elements/settings-data/index.html
   create app/elements/settings-data/demo/index.htm

generator version is 1.2.3

robdodson commented 8 years ago

I'm traveling on vacation till the 23rd but will try to find time to look at this. If anyone wants to submit a PR to fix before I get to it then that would also be awesome :cake: :)

luxedo commented 8 years ago

I've sent a PR! I'm quite new in web development and git, hope it works!

hemanth commented 8 years ago

@ArmlessJohn404 Thanks for the PR, this will be ok after we do a new release.

Update:

Did you check if you are not able to see this again?

This change you made, LGTM, but it's not really fixing the issue yet.

Error: ENOENT: no such file or directory on writeFileFromString.

hemanth commented 8 years ago

@SBoudrias anything suspicious about wiring?

luxedo commented 8 years ago

Should it create a new elements.html when creating an element outside a polymer project? what if it doesn't prompts to add the import to elements.html if you run outside the root of a project? @hemanth Should I create a new PR?

robdodson commented 8 years ago

It was intended to only ever work inside a PSK project. Maybe the problem is folks are running it outside a scaffolded project? To create a standalone element you want to run yo polymer:seed

luxedo commented 8 years ago

Yes, It crashed only when running outside the project. I'm creating an error to address the issue

SterlingVix commented 8 years ago

For what it's worth: I was running yo polymer:element add-name inside my scaffolded project.

I get my error on any combination of answers to the 2 prompts:

aaronmelocik@Vonnegut:/private/var/www/metrodigi/testing/generator-polymer$ yo polymer:element add-name
? Would you like to include an import in your elements.html file? Yes
? What type of test would you like to create? TDD

events.js:85
      throw er; // Unhandled 'error' event
            ^
AssertionError: Trying to copy from a source that does not exist: /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/element/templates/element.html
    at EditionInterface.exports._copySingle (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:45:3)
    at EditionInterface.exports.copy (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy-tpl.js:16:8)
    at module.exports.yeoman.generators.Base.extend.el (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/el/index.js:100:13)
    at /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:358:17)
aaronmelocik@Vonnegut:/private/var/www/metrodigi/testing/generator-polymer$ yo polymer:element add-name
? Would you like to include an import in your elements.html file? No
? What type of test would you like to create? TDD

events.js:85
      throw er; // Unhandled 'error' event
            ^
AssertionError: Trying to copy from a source that does not exist: /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/element/templates/element.html
    at EditionInterface.exports._copySingle (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:45:3)
    at EditionInterface.exports.copy (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy-tpl.js:16:8)
    at module.exports.yeoman.generators.Base.extend.el (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/el/index.js:100:13)
    at /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:358:17)
aaronmelocik@Vonnegut:/private/var/www/metrodigi/testing/generator-polymer$ yo polymer:element add-name
? Would you like to include an import in your elements.html file? No
? What type of test would you like to create? None

events.js:85
      throw er; // Unhandled 'error' event
            ^
AssertionError: Trying to copy from a source that does not exist: /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/element/templates/element.html
    at EditionInterface.exports._copySingle (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:45:3)
    at EditionInterface.exports.copy (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/mem-fs-editor/actions/copy-tpl.js:16:8)
    at module.exports.yeoman.generators.Base.extend.el (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/el/index.js:100:13)
    at /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:358:17)
aaronmelocik@Vonnegut:/private/var/www/metrodigi/testing/generator-polymer$ 
robdodson commented 8 years ago

@SterlingVix try running yo polymer:el and see if that makes a difference. Looks like it's searching for a relative path to the template in the element dir but it only lives in the el dir.

SterlingVix commented 8 years ago

@robdodson Thanks for the reply.

I'm not at that computer anymore (will be back tomorrow), but I will say that the original issue happened regardless of whether I was using element or el. If I remember correctly, the element location just contained a reference to the el location.

I'll confirm tomorrow with el and send the terminal output, but I expect to get the same results.

SterlingVix commented 8 years ago

@robdodson Worked!

First I updated my generator through the yo interface, then I ran the element command with el:

aaronmelocik@Vonnegut:/private/var/www/metrodigi/testing/generator-polymer$ yo polymer:el custom-component
? Would you like to include an import in your elements.html file? Yes
? What type of test would you like to create? None
events.js:85
      throw er; // Unhandled 'error' event
            ^
TypeError: Cannot read property 'replace' of undefined
    at module.exports.yeoman.generators.Base.extend.el (/Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/el/index.js:109:14)
    at /Users/aaronmelocik/.npm-packages/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:358:17)
aaronmelocik@Vonnegut:/private/var/www/metrodigi/testing/generator-polymer$ yo polymer:el custom-component
? Would you like to include an import in your elements.html file? No
? What type of test would you like to create? TDD
   create app/elements/custom-component/custom-component.html
   create app/test/custom-component-basic.html

As reported by other users, I get the elements if I answer "no" to "Would you like to include an import in your elements.html file?", otherwise it fails.

akc42 commented 8 years ago

I have the same problem. Looking at index.js file where the error is reported, I can see the var el declared, but I can't see anywhere in this file where it is being set, before the line the errors.

el = el.replace(...)

I think it might need something like

// make app/elements/elementName/elementName el = path.join(pathToEl,this.elementName);

But I am puzzling why we might have a backslash in there that needs replacing with a forward slash.

FranciscoGutierrez commented 8 years ago

Same error here, crashing with yo polymer:seed

events.js:141
      throw er; // Unhandled 'error' event
      ^
AssertionError: Trying to copy from a source that does not exist: /Users/Francisco/npm/lib/node_modules/generator-polymer/seed/templates/seed-element/.gitignore
    at EditionInterface.exports._copySingle (/Users/Francisco/npm/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:45:3)
    at EditionInterface.exports.copy (/Users/Francisco/npm/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:23:17)
    at module.exports.yeoman.generators.Base.extend.seed (/Users/Francisco/npm/lib/node_modules/generator-polymer/seed/index.js:125:15)
    at /Users/Francisco/npm/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:368:17)
ghost commented 8 years ago

Hi,

Same issue

issues232

samccone commented 8 years ago

Alright, I took a dive into exactly what is happening here and the great news is I have a solution that we can get out to everyone in the next few hours :clap:

On the last release of the project, whoever published to npm did not run git submodule update --init --recursive

What¿ you may be asking yourself...

Well to understand what is going on, lets take a few steps back...... The error that everyone was getting was caused because seed-element.html does not exist at the path screen shot 2015-10-15 at 8 20 41 pm

If you do a fresh clone of this repo you will notice there is nothing in this folder at all!

This got me thinking :cloud: .. What is actually going on. Well way back in in 0ff409ef96980d1ca16400030d756aba7fffadef the project decided to use a git submodule, which means that whoever publishes this package, need to make sure to run git submodule update --init --recursive before publishing which will hydrate the files :)

needless to say I think that that step was skipped on the last publish, Once you run the command everything works like a charm :+1: (and all the maintainers of the project need to do is run the command and bump and publish the generator)

screen shot 2015-10-15 at 8 25 38 pm

screen shot 2015-10-15 at 8 25 32 pm

huzzah! :sparkles: :sparkles: :sparkles: :sparkles: :sparkles:

TLDR

:shipit:

hemanth commented 8 years ago

@samccone :+1: Uber cool!

ragingwind commented 8 years ago

@samccone :beers:

sindresorhus commented 8 years ago

1.2.4 published. Thanks for looking into this @samccone :)

Someone should add a prepublish step that does git submodule update --init --recursive just in case.

SterlingVix commented 8 years ago

@samccone thanks so much for figuring this out! I've been through git submodule hell before - I agree with the suggestion to automate that command wherever possible.

javier-pepe commented 8 years ago

I'm still getting this issue on the latest version

Darwin MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64

yo: 1.4.8 yo polymer: 1.2.4

yo polymer:element bc-util-dropzone
? Would you like to include an import in your elements.html file? No
? What type of test would you like to create? TDD
events.js:85
      throw er; // Unhandled 'error' event
            ^
AssertionError: Trying to copy from a source that does not exist: /usr/local/lib/node_modules/generator-polymer/element/templates/element.html
    at EditionInterface.exports._copySingle (/usr/local/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:45:3)
    at EditionInterface.exports.copy (/usr/local/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy.js:23:17)
    at EditionInterface.module.exports [as copyTpl] (/usr/local/lib/node_modules/generator-polymer/node_modules/yeoman-generator/node_modules/mem-fs-editor/actions/copy-tpl.js:16:8)
    at module.exports.yeoman.generators.Base.extend.el (/usr/local/lib/node_modules/generator-polymer/el/index.js:100:13)
    at /usr/local/lib/node_modules/generator-polymer/node_modules/yeoman-generator/lib/base.js:429:16
    at processImmediate [as _immediateCallback] (timers.js:358:17)

yo polymer:el does work though,

yo polymer:el bc-util-dropzone
? Would you like to include an import in your elements.html file? No
? What type of test would you like to create? TDD
   create app/elements/bc-util-dropzone/bc-util-dropzone.html
   create app/test/bc-util-dropzone-basic.html
robdodson commented 8 years ago

@rootsco I think I have a fix here: https://github.com/yeoman/generator-polymer/pull/244

yo polymer:element is an alias for yo polymer:el and its trying to copy from its own template directory (which doesn't actually exist). The short term workaround is to use yo polymer:el until this patch is landed.