Am using jit tree in my rails 4 application.
http://philogb.github.io/jit/.
While using it in local I am not getting any error. But When I deploy my app into heroku I get the following error on assets precompilation.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
SyntaxError: Invalid regular expression: /(C-1))}z.computePositionStep(A,y);if(C&&x>=C) {B.onComplete();return}}B.onStep(Math.round(x/: Unmatched ')'
(in /tmp/build_tposeydajlt8/app/assets/javascripts/application.js)
Try formatting that particular line in your code. Normally, it throws this error when you have a post/pre-increment before dividing. For example, if you have,
i++/(C-1)
make it
(i++)/(C-1)
This may help, it may not: I was also getting asset pre-compilation errors compiling Jit, so I updated the uglifier gem with bundle update uglifier, and it started working. However, the uglification itself has also been causing problems, so I might just not uglify it since the JS will normally be downloaded compressed and that should provide sufficient file size reduction.
If that doesn't work, another thing you could do is, instead of downloading the full Jit package, just download the bits of Jit you need by using the Custom build option found here: http://philogb.github.io/jit/builder.html ; perhaps the error is caused by a file you don't need.
Thanks
Related
I've got the lovely topojson library working for me in a Rails app locally:
https://github.com/topojson/topojson
and it's allowing us to show some nice geoJSON in a google map like so:
I show it with the map.js file exposed, since that seems to be where the trouble is when we deploy to heroku. On heroku the map.js file gives an error on chrome:
maps-....js:27 Uncaught SyntaxError: Unexpected token export
and a similar error (although on a different line) on firefox:
SyntaxError: export declarations may only appear at top level of a module maps-...js:1
I've been in touch with heroku support who suggested locking down our npm version, as it seems like the minified js file is ending up with slightly different content locally than on heroku. I note that I've done everything I can to replicate production mode locally, clobbering and recompiling the static assets etc. and running like so:
RAILS_SERVE_STATIC_FILES=true DEVISE_SECRET_KEY=1234 AIRBRAKE_PROJECT_ID=1234 RAILS_ENV=production bundle exec rails s
but try as I might I cannot replicate the issue on my dev machine.
You can see all the gory details in this PR https://github.com/AgileVentures/LocalSupport/pull/1069 and I was wondering if anyone had any ideas about anything else that could be a difference between my dev machine and heroku that could be leading to the javascript files compiling differently? On heroku we have the following:
export*from"topojson-client";export*from"topojson-server";export*from"topojson-simplify
but there is no mention of the offending export keywords in the static assets compiled locally, but there they are in the files on the heroku server. I've been trying all sort of methods to ensure that I'm deleting cached files and that that the changes I am making are being reflected both locally and on heroku.
I've also been investigating ways to try and handle the export keyword (new in es6) but that seems like an even deeper rabbit hole, i.e. sprockets 4 or webpack or similar.
Anyhow, if anyone has any thoughts on other things that could cause heroku to be operating differently here I'd love to hear them, so I can either lock them down or work out how to replicate the bug locally.
Many thanks in advance
Heroku support are saying that the problem here is using npm with the asset pipeline and the better approach would be to use webpacker
I'm totally new to npm and node.js so please forgive me if I'm not giving the right detail. I'm writing a plugin for a website that uses an out-of-the-box framework in npm. It was working fine as I coded away happily, but at some point it started trying to compile a file that no longer exists.
I use npm run start to compile my html file (which contains all the javascript code as well) and get this error:
ℹ info Compiler will compile ./src/plugin.html
ℹ info Transpiling with babel
✖ error Error
SyntaxError: unknown: Unexpected token (555:3)
553 |
554 |
> 555 | });
| ^
What breaks my brain is that this simple syntax error is not present in ./src/plugin.html (I've quadruple checked this fact). This obvously pertains to an earlier version of the file.
Does npm have some kind of cache that would cause it to compile an older version of a file? I've noticed that if I remove most of the code, it compiles again, but when I replace the code it breaks again. It seems that if the file is somewhat similar to its cached version, it tries to compile the cached version and not the current version.
I've tried clearing the cache with npm --force cache clear but to no effect.
Any suggestions?
For anyone who has a similar problem with compiling code with npm, I discovered that my problem was indeed a simple syntax error. But it seems that npm became confused about what the compile error actually was. It was pointing to a line of code that did not exist in the file, and I have no idea where it got this from.
The syntax error that was the culprit in this particular case was a missing }; to close a wrapped set of functions.
So it seems that the lesson here is not to put too much trust in npm's ability to understand what syntax errors are inciting a compile error.
the only way I was able to get out of this scenario was:
rename the file
refactor the references to it, so it will compile
npm start
stop it
rename and refactor the file back to its original name
Do you try to use rebuild or something like that or npm cache clean insted of npm --force cache clear?
I had the same problem after a cancelled git rebase. The only way I could fix this was to change something in those files & revert the change after.
I recently faced this issue. If you are using typescript in your project, you may have used a wrong configuration in your tsconfig.json file that may have built the typescript files into their corresponding js files and these js files are the ones that runs every time you run the project.
for me clear catching my browser it works
Fixed by Pressing Ctrl+s !
For me vsc by default doesn't save automatically changed code like PyCharm.
Try to delete .next folder it will delete the catched files
I'm trying to learn Ember.js and so I started to read some installation guides with npm. Then I went to try a small Getting Started tutorial guide they have on their website. I followed each step without to much exploration just to see if it worked well.
Everything went fine, the app was loading and acting as expected on localhost:4200 server and it was pretty nice to develop actually. The problem was on the final step, where you have to build the app with your command line using ember build --env production and the dist/ folder will have your final code. The command line trown some errors and when I went to the index.html file on dist/ folder, the page was blank in Chrome.
This happened in MacOS and Windows 10 to.
I'm using ember-cli version 2.4.3, node version 4.4.3 and npm version 3.8.9 on a Windows 10 machine x64 architecture.
The error trown by the command line was:
Cleanup error.
ENOTEMPTY: directory not empty, rmdir 'C:\root\tut\tmp\template_compiler-output_path-NGSFwxV3.tmp\modules\ember-cli-app-version'
Error: ENOTEMPTY: directory not empty, rmdir 'C:\root\tut\tmp\template_compiler-output_path-NGSFwxV3.tmp\modules\ember-cli-app-version'
at Error (native)
at Object.fs.rmdirSync (fs.js:758:18)
at rmkidsSync (C:\root\tut\node_modules\ember-cli-htmlbars\node_modules\broccoli-persistent-filter\node_modules\broccoli-plugin\node_modules\quick-temp\node_modules\rimraf\rimraf.js:247:11)
at rmdirSync (C:\root\tut\node_modules\ember-cli-htmlbars\node_modules\broccoli-persistent-filter\node_modules\broccoli-plugin\node_modules\quick-temp\node_modules\rimraf\rimraf.js:237:7)
at fixWinEPERMSync (C:\root\tut\node_modules\ember-cli-htmlbars\node_modules\broccoli-persistent-filter\node_modules\broccoli-plugin\node_modules\quick-temp\node_modules\rimraf\rimraf.js:150:5)
at rimrafSync (C:\root\tut\node_modules\ember-cli-htmlbars\node_modules\broccoli-persistent-filter\node_modules\broccoli-plugin\node_modules\quick-temp\node_modules\rimraf\rimraf.js:216:26)
at C:\root\tut\node_modules\ember-cli-htmlbars\node_modules\broccoli-persistent-filter\node_modules\broccoli-plugin\node_modules\quick-temp\node_modules\rimraf\rimraf.js:245:5
at Array.forEach (native)
at rmkidsSync (C:\root\tut\node_modules\ember-cli-htmlbars\node_modules\broccoli-persistent-filter\node_modules\broccoli-plugin\node_modules\quick-temp\node_modules\rimraf\rimraf.js:244:26)
at rmdirSync (C:\root\tut\node_modules\ember-cli-htmlbars\node_modules\broccoli-persistent-filter\node_modules\broccoli-plugin\node_modules\quick-temp\node_modules\rimraf\rimraf.js:237:7)
Built project successfully. Stored in "dist/".
File sizes:
- tut-d41d8cd98f00b204e9800998ecf8427e.css: 0 B
- tut-faee034545d48621fa86656f6c15f508.js: 9.15 KB (1.99 KB gzipped)
- vendor-d41d8cd98f00b204e9800998ecf8427e.css: 0 B
- vendor-eeea1e3023f3e98422c781bcc7b2588e.js: 689.89 KB (180.23 KB gzipped)
I don't know if this affects in anything but I've runned the ember build command while the ember server was still rilling.
I wanted to understand if I'm doing something wrong, or if this ember tutorial is outdated, of if anyone has experienced this same problem and how to solve this issue.
Thanks
Just a suggestion. I wouldn't run ember b or ember build while the server is running within another console window.
Both ember build end ember serve run the broccoli build pipeline, wich depends on temporary files in the tmp dir. If you start it twice this can lead to problems. Stop your server for the build.
I found the answer in this issue on github:
https://github.com/ember-cli/ember-cli/issues/3861
Turns out I didn't have production configured base URL and other stuff I should have.
I am currently trying to get into NodeJS together with the SailsJS framework.
And I want to use coffeescript on the serverside aswell, but after converting all files in config/*.js to config/*.coffee properly with js2coffee, I get the following error when trying to start up the app:
config/400.coffee
SyntaxError: Unexpected token ILLEGAL
pointing to the first character in the file, which is a hashtag for a coffee comment. So it seems the app does not recognize the file as coffeescript, but searching for standard js instead.
I tried installing the package coffee-script and requireing it in
app.js
require('coffee-script');
require('sails').lift(require('optimist').argv);
but it doesn't help.
If I delete 400.coffee, the error appears in the next file 403.coffee etc.
What am I doing wrong? Isn't coffeescript allowed in the config files or am I missing something?
Coffeescript 1.7.0, released Jan 28th, 2014, changed the require('coffee-script') behavior to only load the compiler itself. Now, do load the automatic compiler for .coffee files, you must call require('coffee-script/register') before loading any coffeescript files.
Keep in mind that using this will mean that every .coffee file will be recompiled every time you start node, which could increase startup times. That may or may not be important to you though.
I am currently in a web development class and we are using Ruby on Rails.
I am using Ruby v1.9.2 and Rails v3.1.1.
My initial problem started when I tried to execute 'rails server'.
I would get the following error:
C:\Sites\rorProjects\basicRoRProject>rails server
C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/execjs-1.2.13/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime.
See https://github.com/sstephenson/execjs for a list of available runtimes.(ExecJS::RuntimeUnavailable)
I have done some reading and the general consensus is to install the gems 'execjs' and 'therubyracer'. 'execjs' installed just fine, however when I tried to install 'therubyracer' I got the following error:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
Check the mkmf.log file for more details.
You may need configuration options.
I then did some more reading and found a couple of people said to check that they had the gem 'libv8', which was required for 'therubyracer'. I did that and discovered that I didn't have it, so I then went to install that and got the same error that I did for 'therubyracer'.
I'm at a loss to think of anything else to do. Any help would be greatly appreciated.
Thanks guys!
THIS PROBLEM HAS BEEN SOLVED.
So, with the help of one of my classmates who had a similar problem, I installed Node.js using the Windows installer (this gave me a JavaScript run-time environment). I then added it to the path in the local variables.
So, with the help of one of my classmates who had a similar problem, I installed Node.js using the Windows installer. I then added it to the path in the local variables.