UPDATE 2
I've filed an issue at the ember-cli repo describing simple steps to reproduce the issue: https://github.com/ember-cli/ember-cli/issues/4015.
UPDATE
This is related to using in-repo-addons. The ember compiler does not choke when using this syntax in your regular app. I will be filing a bug report at http://github.com/ember-cli/ember-cli shortly with steps to reproduce and will link back to the issue here when it is ready.
I caught the bug for es6 and started using the object literal method shorthand:
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement() {
// stuff I want to do once we're in the DOM
}
})
but it chokes when running ember build --environment production. Thoughts?
Build failed.
Unexpected token punc «(», expected punc «:»
Ember-cli uses babel which does support object literal shorthands.
See:
https://babeljs.io/docs/learn-es6/
In Repo Addons (currently) require ember-cli-babel as a dependency.
$ cd lib/<your addon>
$ npm install ember-cli-babel --save
$ cd ../..
$ ember build --environment production
Related
I have an Ember.js addon which Watchman does not seem to operate correctly with. Any changes made to the addon-name/app files do not trigger a rebuild. However, changes to files within addon-name/tests do trigger a rebuild.
I have a .watchmanconfig file set up as follows...
{
"ignore_dirs": [ "tmp", "dist", ".idea", "docs", ".git", "node_modules" ]
}
After running the dummy app with ember s, I checked watchman watch-list and do not see the addon listed in the "roots" category. I've added it manually, but that does not help either, as I'm guessing ember s has to tell watchman what to do when the files are changed.
Any ideas on what might be happening?
OS: Mac OSX High Sierra (10.13.4)
Ember: v3.1.0
Node: v8.11.1
NPM: 6.0.0
Yarn: 1.5.1
If you are using symlink then some times watchman does not track the changes, to track your changes in your addon's index.js add following code
module.exports = {
name: projectName,
isDevelopingAddon: true
};
Hope it helps
I'm building an Ionic 2 (RC0) application and I'm trying to use node-uuid by following the official documentation.
I've done:
$ npm install --save node-uuid
$ npm install --save #types/node-uuid
node-uuid seems to be using the default export approach, so I'm importing it in my typescript file like this:
import uuid from 'node-uuid';
And using it as follows:
console.log(uuid.v4);
However, my app doesn't come up and I see this error in the logs:
TypeError: des$3 is undefined
What am I missing?
Most resources for Angular 2 recommend using the typings CLI to install the type definitions, but this made no difference for me. I tried:
$ npm install --global typings
$ typings install --save node-uuid
$ ionic info
Your system information:
Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on.
6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS
Node Version: v6.6.0
******************************************************
Dependency warning - for the CLI to run correctly,
it is highly recommended to install/upgrade the following:
Please install your Cordova CLI to version >=4.2.0 `npm install -g cordova`
******************************************************
Please note that node-uuid is deprecated. They merged with another project and now it's only called uuid. Everything up to the point of installing the #types library is correct. (note that you will have to redo those steps using just 'uuid' not 'nod-uuid')
However,
console.log(uuid.v4);
does not generate an id. As per the documentation you need to specify in your import which version of uuid you want to use and then call your variable as a method: uuid();
From docs: [Deprecation warning: The use of require('uuid') is deprecated and will not be supported after version 3.x of this module. Instead, use require('uuid/[v1|v3|v4|v5]') as shown in the examples below.]
Here is a code example using uuid/v1:
import { Component } from '#angular/core';
import uuid from 'uuid/v1'; //here change 'v1' with the version you desire to use
#Component({
selector: "page-uuid",
templateUrl: "uuid.html"
})
export class uuidTestPage {
id = uuid();
constructor() {
console.log(this.id); // outputs id. For example: 298da400-1267-11e8-a6e5-3148ee6706e9
}
}
After you serve your app and enter the uuidTestPage you should see the id logged to the console. The format of the id will vary depending on the version you use:
Version 1 (timestamp): my example.
Version 3 (namespace)
Version 4 (random)
etc...
Happy coding!
you can try it: (angular2-uuid)
npm install angular2-uuid --save
......
import { UUID } from 'angular2-uuid';
...
let uuid = UUID.UUID();
it works on angular 2 & ionic 2
i'm using ember-cli version 0.1.15 and it fails to run a newly created ember app.
Here are the commands issued to install ember-cli and to create the new app:
$ npm uninstall -g ember-cli
$ npm cache clean
$ bower cache clean
$ npm install -g ember-cli#0.1.15
$ ember new Query
$ cd Query
$ ember serve
While the ember service starts up, it attempts to parse the jquery intro.js file which is a partial module file because it does not close the IIFE function. I guess the outro.js file is the companion file that closes the intro.js.
Below is the resulting error after invoking ember serve
version: 0.1.15
Livereload server on port 35729
Serving on http://0.0.0.0:4200/
File: bower_components/jquery/src/intro
Unexpected token (45:0)
SyntaxError: Unexpected token (45:0)
at raise (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:333:15)
at unexpected (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1366:5)
at parseExprAtom (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:2153:7)
at parseExprSubscripts (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:2012:28)
at parseMaybeUnary (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1995:16)
at parseExprOps (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1946:24)
at parseMaybeConditional (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1930:16)
at parseMaybeAssign (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1913:16)
at parseExpression (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1898:16)
at parseStatement (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1586:38)
at parseBlock (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:1826:18)
at parseFunctionBody (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:2378:19)
at parseFunction (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:2277:5)
at parseExprAtom (/Users/Steffen/Temp/Query/node_modules/ember-cli/node_modules/broccoli-es6modules/node_modules/esperanto/node_modules/acorn/acorn.js:2141:14)
I tried reinstalling ember-cli and clearing the npm and bower caches. Any other caches that need to be cleared?
Try not capitalizing the new ember app's name:
ember new query
Also, you don't need to specify the ember cli version:
npm install -g ember-cli
In case query is a reserved keyword, if you still get errors, try another name.
I have successfully created a small application using ember-cli. I tried pushing it to gh-pages branch of my github repo but it shows error in browser console
Uncaught ReferenceError: require is not defined
loading of vendor.js and vendor.js files from dist/assets is also failing.
I'm not able to run standalone ember app from dist folder in local machine as well, same errors.
has anyone tried it. if yes how to do it correctly?
Since December 2014 there is also an ember-cli addon for this.
First make sure to have set modulePrefix in config/environment.js to your repo's name on github. E.g., for https://github.com/username/my-cool-repo it should be modulePrefix: 'my-cool-repo'.
Then follow these instructions:
Install the addon.
$ ember install:addon ember-cli-github-pages
Commit the changes made by the addon.
$ git add . && git commit -m "Installed addon ember-cli-github-pages"
Create the gh-pages branch with only the necessary files.
$ git checkout --orphan gh-pages && rm -rf `ls -a | grep -vE '.gitignore|.git|node_modules|bower_components|\.\/|\.\.\/'` && git add . && git commit -m "Initial gh-pages commit"
Switch back to your source branch (most likely master).
$ git checkout master
Build your ember app to the gh-pages branch.
$ ember gh-pages:commit --message "Initial gh-pages release"
Push everything (or at least the gh-pages branch) to github.
(This was different for ember-cli <= 0.1.4 and might change again in the future. Make sure to visit the addon's readme.)
As the comments already say: change the baseUrl in config/environment.js to the name of the GitHub repository you are pushing the app to. For example:
Your GitHub respository is called myEmberApplication and resides in
https://github.com/yourUsername/myEmberApplication.git
then the URL to this project's gh-pages would be
https://yourUsername.github.io/myEmberApplication
So in your case you have to change the baseUrl from / (default) to /myEmberApplication.
The reason why you have to do this is because ember-cli adds the <base> header to your index.html file.
I am learning to configure Laravel Echo Socket.js and following an article here
Code in bootstrap.js is below
import Echo from "laravel-echo"
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});
When I run the above code, it says, Cannot find module "laravel-echo"
I am not using pusher and redis. In the above reference page, I think, there is no installation guidelines given for only socket.io
Can somebody explain if I am missing anything?
I solved the same problem installing the following packages:
npm install --save laravel-echo pusher-js
I needed to install below packages.
npm install -g laravel-echo-server
then following the step by step instruction as give here
Finally put below code before any js file.
<script src="http://{{ Request::getHost() }}:6001/socket.io/socket.io.js"></script>
the issue is here:-
import Echo from "laravel-echo"
you will write it as:-
import Echo from 'laravel-echo';