mercredi 1 juillet 2015

npm install ember-cli fails on ubuntu trusty in vagrant virtualbox

I have not been able to successfully install ember-cli. I finally was able to run:

sudo npm install -g ember-cli

But when running:

user@host:~ ember new ember-app

I get:

/usr/bin/env: node: No such file or directory

I installed node.js from the repositories using sudo apt-get install nodejs and same with npm.

I have installed bower and tried to re-install npm. Here is the last error:

user@host:~ npm install -g ember-cli
npm http GET http://ift.tt/1Qsp0Yf
npm http 200 http://ift.tt/1Qsp0Yf
npm http GET http://ift.tt/1ALYMOL
npm http 200 http://ift.tt/1ALYMOL
npm ERR! Error: shasum check failed for /home/user/tmp/npm-14461-xfhNCJKF/1435776262780-0.6301117099355906/tmp.tgz
npm ERR! Expected: fefcd9fe7faf276a5a68c8bfcc92288c0f0678d5
npm ERR! Actual:   c120ca4196f11da6e51f9c8ebb273439dcfee615
npm ERR!     at /usr/lib/nodejs/sha/index.js:38:8
npm ERR!     at ReadStream.<anonymous> (/usr/lib/nodejs/sha/index.js:85:7)
npm ERR!     at ReadStream.EventEmitter.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:920:16
npm ERR!     at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://ift.tt/wnQOXn;
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.13.0-55-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "ember-cli"
npm ERR! cwd /home/user
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/user/npm-debug.log
npm ERR! not ok code 0

For clarity, I am able to install other items using npm. Just not ember-cli.

UPDATE:

I am getting similar errors that I've received in previous executions of npm install -g ember-cli when run the following:

npm install -g latest-version

Received the following error:

npm http GET http://ift.tt/1pifSHE
npm http 304 http://ift.tt/1pifSHE
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/latest-version'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/latest-version']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/latest-version',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/latest-version',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/lib/nodejs/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/lib/nodejs/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.13.0-55-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "--global" "latest-version"
npm ERR! cwd /home/user
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /usr/local/lib/node_modules/latest-version
npm ERR! fstream_path /usr/local/lib/node_modules/latest-version
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/latest-version'
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/nodejs/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/user/npm-debug.log
npm ERR! not ok code 0




calling set on destroyed object setInterval in acceptance tests

I know that there are like 5 topics with the same name here, but they seems to be unrelated to my case: I'm getting this error in acceptance tests, and the reason for that is the countdown component built with Ember.run.later.

Maybe someone know how to cure that?




EmberJS Error message: Assertion Failed: Cannot find model name

I am in the mids of following: Vic Ramon EmberJS tutorial. I reached the point where I am trying to list the leads and have the following setup:

Adapter

App.Store = DS.Store.extend()
App.ApplicationAdapter = DS.ActiveModelAdapter.extend()

DS.RESTAdapter.reopen
  namespace: 'api/v1'

Controller

App.LeadsController = Ember.ArrayController.extend
  sortProperties: ['firstName', 'lastName']

Model

App.Lead = DS.Model.extend
  firstName:  DS.attr('string')
  lastName:   DS.attr('string')
  email:      DS.attr('string')
  phone:      DS.attr('string')
  status:     DS.attr('string', defaultValue: 'new')
  notes:      DS.attr('string')


  fullName: (->
    @get('firstName') + ' ' + @get('lastName')
  ).property('firstName', 'lastName')

Routes

App.LeadsRoute = Ember.Route.extend

  model: ->
    @store.findAll 'lead'

Router

App.Router.reopen
  location: 'auto'
  rootURL: '/'

App.Router.map ()->
  @resource 'leads', path: '/'
  @resource 'lead', path: 'leads/:id'

Template

<article>
    <h1>Leads</h1>
    <ul>
      {{#each lead in controller}}
        <li>{{#link-to 'lead' lead}}{{/link-to}}</li>
          {{lead.fullName}}
      {{/each}}
    </ul>
</article>

The issue simply is when I redirect my browser to http://localhost:3000 it shows me the list of fullNames but doesn't show me the anchor links. Screenshot Also another thing I seem to get in my chrome browser console is:

Error message: Assertion Failed: Cannot find model name

Bonus Question

From reading a few books an tutorials I understand that you can include mixins as a way of injecting additional properties into Controllers or Views. So for example you can do:

Ember.View.extend(App.Editable)

But can you include a mixin into a model? As in can you do:

App.Lead = DS.Model.extend(App.SomeMixin)




Search if is a match and ignore Caps and Space

I build a filtering for my app that uses a search box. I have a problem that everytime I type Caps or I add space the search box filtering does not occur. I want to be able to filter not matter the circumstance. If the character is a match 'Filtered'.

{{input type="search" value=theFilter placeholder="ID, group name..."}}

theFilter: null,

filterHotel: function() {
    var model   =  this.get('model');
    var theFilter = this.get('theFilter');
    return model.filter(function(hotelRequest){
            return (hotelRequest.get('inquiry.name') && hotelRequest.get('inquiry.name').search(theFilter) != -1)
                || (hotelRequest.get('inquiry.id') == theFilter);             
    });
}.property('theFilter'),




Ember : downgrading ember with bower install

I've been switching to the 1.13.2 version of ember on a git branch, and now I want to come back to 1.11.1 when going back to an other branch.

I've been running npm install and bower install without failure.

But when I run ember server I run into the following error :

Missing bower packages: 
Package: ember
  * Specified: 1.11.1
  * Installed: 1.13.2

Run `bower install` to install missing dependencies.

Running bower install again does not solve the problem, neither does bower cache clean.




Ember on IE7 - Object doesn't support this action

I have been successfully running an ember app on IE8 and above. Now I need to support IE7 as well.

I have now installed ember.js v1.0.0 but I am getting the following error: "Object doesn't support this action". Seems like method.apply is the problem.

here:

if (method) {
    // Older IE doesn't support apply, but Chrome needs it
        if (method.apply) {
            return function() {
                method.apply(consoleObj, arguments);
            };
         } else {
            return function() {
            var message = Array.prototype.join.call(arguments, ', ');
            method(message);
          };
          }   } }

Any ideas on how to get past this problem? This is line 390 of ember.js

Thanks!




Ember model inside models sub folder

I am using ember cli and Ember Data. My requirement is to keep ember model in Models sub folder. Ex. My Model Name is "mymodel" and have kept it inside app\models\myfolder\mymodel.js folder. store.find works with following syntax - this.store.find('myfolder.mymodel'); Above syntax generates service URL as http://localhost:4200/myfoldermymodel where as my service can be accesssed using URL http://localhost:4200/mymodel only. If I try to override buildURL or pathForType on RESTAdapter though service call is successful model is not getting populated. Any help appreciated. at one line question is how to put model in subfolders?