require 'coffee-script/register' - unexpected string - node.js

I'm using coffee-script 1.7.1 (or I want to use it). Can't make it work, though.
first line of my server.coffee file is require 'coffee-script/register' and I get the oh-so familiar error SyntaxError: Unexpected string. On version 1.6.3 all was well.
In a different project I've successfully used coffee 1.7.1 when the starting file was server.js, but don't want to do it here.
Has anyone made this work? Preferably without making some sort of weird workarounds.

I'm using coffescript 1.7.1 and require 'coffee-script/register' with server.coffee.
Not sure if this applies to your situation, but I spent many hours on a similar error before I realized that I was launching my app from the wrong instance. For example, /usr/bin/coffee instead of /usr/local/bin/coffee.
which coffee gave me the correct path.

I think that you only will need to require coffee-script/register when you are writing JS and want to load a coffeescript file.

Related

cannot find module node:events but node version is 16.6

My code is getting this error with using a html script using discord.js runned by electron(nodeIntergation is true and node is working in html)but I get the error: cannot find module node:events when I search it on web it says upgrade your node to 16.6 but it still don't work on 16.6
Here is the node -v command to proof
I dont't know why this is happening can someone help?
I don't know is this a good solution or gonna cause bugs but when I change some of the code in module's code it just worked(changing node:x to x just an example not real module)thanks to #Darren Cook because the thing he said in the comments make me looking to some documention on node.js and I see the modules start to calling module_name to node:module_name from some version(I guess 16.6)like I said I don't know is this a good solution but worked for me no bugs till this moment

Grunt still unable to handle ES6 imports?

I am working on a project under NodeJS that uses ES6 imports/exports (hence having set type: module in its package.json) and want to automate some tasks using Grunt. Now, I absolutely love grunt, but it appears to me that even in 2022 it is still not able to work nicely with ES6 modules? I always get an error saying "require() of ES Module /vagrant/Gruntfile.js from /vagrant/node_modules/grunt/lib/grunt/task.js not supported."
I understand where this is coming from, and I do understand there are workaround options - in particular, renaming Gruntfile.js to Gruntfile.cjs and passing it to grunt with the --gruntfile command line option. But that is incredibly annoying - it makes the command six times as long as it would be if I could just run grunt and be done with it. Pretty much the same goes for transpiling with something like Babel: That is exactly the kind of thing grunt is intended to handle in the first place, so it feels a bit like the horse riding the jockey. I feel like this should "just work".
Am I missing something here, or is grunt really unable to handle ES6 imports out of the box?
Actually, looking at the grunt github page it appears that a recent commit has addressed it.
I guess this issue will therefore be resolved in their next update.

TypeError after upgrading Node version

I'm trying to fix this problem for 6 hours now and I'm slowly starting to lose my mind, so please excuse my generic question.
First of all I am using:
Node: 8.10.0 | npm: 5.6.0 | Yarn: 1.5.1
I just upgraded my project to Node v8 and npm refused to install all dependencies, so i installed yarn which fixed the issue immediately.
My sources are compiled using Laravel Mix which utilises Webpack, Babel, ... internally.
Installing and compiling of my sources works perfectly fine now but for some reason my compiled js file is not working anymore (even if I downgrade to the previous Node version - 6.10.0).
Uncaught TypeError: fn.bind is not a function
at nativeBind (admin.js?id=8c4a6887899977ba8021:72515)
at initMethods (admin.js?id=8c4a6887899977ba8021:75849)
at initState (admin.js?id=8c4a6887899977ba8021:75617)
at Vue._init (admin.js?id=8c4a6887899977ba8021:76936)
at new Vue (admin.js?id=8c4a6887899977ba8021:77037)
at Object../resources/assets/js/admin.js (admin.js?id=8c4a6887899977ba8021:83350)
at __webpack_require__ (admin.js?id=8c4a6887899977ba8021:20)
at Object.1 (admin.js?id=8c4a6887899977ba8021:83790)
at __webpack_require__ (admin.js?id=8c4a6887899977ba8021:20)
at ./node_modules/babel-loader/lib/index.js?{"cacheDirectory":true,"presets":[["env",{"modules":false,"targets":{"browsers":["> 2%"],"uglify":true}}]],"plugins":["transform-object-rest-spread",["transform-runtime",{"polyfill":false,"helpers":false}]]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./resources/assets/js/components/Autocomplete.vue.Object.defineProperty.value (admin.js?id=8c4a6887899977ba8021:63)
I have aboslutely no ideas what this error means let alone what causes it.
I know that the error message is pretty generic and could probably mean a lot of things but hopefully someone knows what it means given my context.
Thanks!
#Ortomala Lokni's answer pushed me in the right direction.
For some reason I thought my problem was related to my build scripts, npm, webpack or anything of that sort, which - of course - it was not.
Event though it wasn't really an API change as he suggested there was simply a wrong call to the VueJS constructor in my JS file which, for some reason, had been ignored by a previous release of VueJs but apparently not by the current one.
For anyone experiencing some weird bugs that just don't make sense I recommend the following:
First of all: Determine what really is your problem - if it compiles it is most certainly not related to your JS build
Comment out all of your JS code in your main file
The error should be gone at this point
Narrow down the error by trying to uncomment line by line (or block by block) and test your code after each uncomment
Even though this steps might seem obvious you can easily forget about such simple thing because of the million things that could possibly break when working with modern JS.
Sometime when you upgrade libraries you have to adapt some code. As Javascript is not a typed language, the problem does't appears at compile time but at run time.
In your case, I suppose that you have a problem similar as this one.
Check which libraries yarn has upgraded and verify if some API has changed.

In typescript, how to restrict a typing reference to a certain file?

I'm trying to cleanly write some universal javascript code, for node and browser.
Most of the code is env-agnostic, however, some implementation parts detect the environment (node or browser) and conditionally execute different code.
I would like to activate node typings ONLY for those specific files. However, I couldn't find a way to do so. Either:
node typings, when referenced in even one file only, are made effective for all files (bad, since I could inadvertently rely on node specificities)
if not referencing node typings at all, typescript obviously complains about a lot of unknown definitions, which would be painful to patch by hand
Do anyone has a clean way of activating some type definitions for a selected set of files ?
It's not possible at this time.
A solution: building node-dependant and node-independant files separately. This could be done automatically with a script.

Codekit 2.0.5 Not Recognizing Compass

I have been pulling what hair I have left out. I just downloaded Codekit this week and want to redesign my own site using Compass/SASS/Susy. I have tried several ways to get it to work, the preference in Codekit to point at the executable path. I am really excited to get started on this new endeavor, but I can't seem to get by the setup. Any help would be greatly appreciated! Thanks.
Is your project set up correctly? Susy 2 requires SASS 3. CodeKit 2 has an option to use libSASS instead of SASS (I use it). There are other dependencies for which I use Bundler. If you use Bundler to set up your project, it will add 'require 'compass/import-once/activate' to your config.rb. Other than that, there is no specific need to require or import compass. Do you have a CodeKit error message that you can post to let us see what is going wrong?
I assume that you are using Susy 2. If you are using Susy 1 you must add #import "susyone"; to your config.rb. But I expect you know that already.
Re your comments:
Using Bundler, my Gemfile includes:
gem "susy", "~>2.1.0"
gem "sass", "~>3.3.0"
gem "breakpoint", "~>2.4.0"
so these must be installed on your system accessible to susy. CodeKit doesn't need compass but my config.rb file includes these:
require 'compass/import-once/activate'
require 'breakpoint'
require 'sassy-buttons'
obviously you may not be using sassy-buttons.
The documentation for Susy2 is extensive and is available at http://susydocs.oddbird.net/en/latest/. You don't say how you set up your project, but I assume that your CodeKit setup points to the correct files from SCSS to compiled CSS.
You need to '#import susy' in one of your .scss files. (I'm not sure that that is necessary anymore).

Resources