shadow-cljs watch app error on luminus page - web

I am using luminus to build a webpage. I want to use clojure script so I created a project with
lein new luminus test +cljs
When starting the webpage I get the following message:
If you're seeing this message, that means you haven't yet compiled your ClojureScript!
Please run shadow-cljs watch app to start the ClojureScript compiler and reload the page.
so I installed and tried to run
npx shadow-cljs watch app
and get the following error:
shadow-cljs - config: /Users/jonas/Dropbox/prog/web/clojure/luminus/test/shadow-cljs.edn
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
Executable 'lein' not found on system path.
i've looked everywhere but I cannot solve this problem. Any ideas?
update:
ok, this is what I have done to temporarily solve this:
First install in the test dir:
npm install react react-dom create-react-class
then run lein directly:
lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
so it is not suppose to be like this, but this is the closest that I get.

ok, I looked after a path variable to set but could not find one. So I simply copied lein from ~/bin/lein (my home dir) to /usr/local/bin and now it found it and it works.
Strange that there is no way to set this for shadow

Related

CodeMix/Eclipse cannot find 'react/jsx-dev-runtime'

I'm completely new to React, Node, NPM, and CodeMix in Eclipse. I'm a veteran java developer and so want to use eclipse over VSCode for familiarity. I'm following this tutorial:
https://www.genuitec.com/react-tutorial-getting-started/
I get to step 5 and run
react-scripts start
The result:
./src/index.js
Module not found: Can't resolve 'react/jsx-dev-runtime' in 'C:\temp\workspace\CCFPortal\src'
I created my project via the new project to create a React project. The wizard added all the standard code. Bringing up the terminal gave me some issues because the terminal doesn't seem to set the path to bring nodejs.exe into scope, so I did it manually in the terminal window. Adjusting the properties in window->preferences terminal+ doesn't seem to ever take effect.
I did the following in npm (in addition to the steps in the tutorial) because there were two 'warnings' in the markers view that suggested it. As near as I can tell, all commands were successful whether from the tutorial or these two (though it does flag some 'vulnerabilities' in npm that I force fixed).
npm install #types/react
npm install #types/react-dom
It is indeed true that there is no react/jsx-dev-runtime under that src folder. There's NOTHING there but the src. But I'm unclear why it wasn't there given that I ran npm install and the other things suggested in the tutorial.
Can someone help explain my pathing issue in the terminal and especially why npm is doing this when I run react-scripts start?

atom + mocha on windows = spawn mocha ENOENT

My goal is to run mocha unit tests by Atom, which is installed on Windows and also my src code resides. this should work independently from my Meteor App which is running on a different (Linux) machine.
Basically my setup is like this:
I have my repo and sourcecode:
c:\Users\Me\repos\meteor
My tests are inside:
c:\Users\Me\repos\meteor\tests
I have Node:
c:\Program Files\nodejs
installed with "npm i -g mocha --save-dev"
And i try to use this package https://github.com/Tabcorp/atom-mocha-test-runner but i can switch to another package if necessary.
What I've tried so far:
I edited my settings for the atom-mocha-test-runner:
Mocha command: C:\Program Files\nodejs\node_modules\mocha\.bin\mocha
Mocha command: C:\Program Files\nodejs\npm mocha
But each time i try to run my test via dropdown menu (Run Mocha Test), i get this error:
Mocha Test Results:
Node binary: C:\Program Files\nodejs\node.exe
Root folder: C:\Source\Repos
Mocha command: undefined
Path to mocha: mocha
Debug-Mode: false
Test file: tests\unit\first.js
Selected test: should return url
Failed to run Mocha
spawn mocha ENOENT
Anyone know what i miss or do wrong?
Still having no idea about why the package isn't working, I'm going to give a cop-out answer. If we figure out how to make it work, you can accept that answer instead. process-palette gives you the ability to run highly specific command-line instructions from Atom commands. Here's an example of a command that runs mocha in the project path for the current file with the same hotkey and also conveniently organized into its own menu item:
The disadvantage of this approach is that you have to know how to use the external program yourself. Packages like mocha-test-runner are designed to remove that need from the user, but as we can see here, sometimes the package doesn't know what it needs to be doing. The disadvantage is mitigated by the fact that you only have to learn the command for long enough to set up the configuration to run it, and from that point on it's very easy.
Advantages versus other packages include the ability to precisely control what's going on. Say you have multiple top-level folders in the current project, and they have different test suites. A package like mocha-test-runner can get the path from the active file, or from the project. If the developer chose to grab the project path, then you're going to have trouble running individual test suites. With the configuration I've shared, the command will always be run in the absolute path of the current file's project folder, so the tests will be run for whichever file you're working on at the time.

Issue with Node-based Cordova Hook

I'm playing around with the Cordova hooks capabilities and I'm trying to test using a node application as a hook. In this article: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ it references running node applications, so I know it's possible.
I've created a simple node application that I'm using to test the before prepare and after prepare process:
#! /usr/bin/env node
console.log("this is a node module");
When I run my prepare, I get the following error:
C:\Users\jwargo\dev\lunchmenu>cordova prepare
The system cannot find the path specified.
Hook failed with error code 1: C:\Users\jwargo\dev\lunchmenu\hooks\before_prepare\test.js
I can't find any information anywhere about what an error code of 1 means here.
I've tested the node code and it runs fine with "node test.js" and when I execute test.js from the command line Windows simply launches my default editor.
So, can anyone tell me what I'm doing wrong or what I need to do to be able to execute a node application as a hook with the Cordova CLI?
Figured it out with some help from the Cordova dev team. The space in my shebang was causing the problem. I removed it and the problem went away.

Downloading source files cache modernizr.load.1.5.4.js Grunt Build Stall

I have been using Yeoman to start building with web apps and such for maybe the last month. And I have been running into some issues and have been able to resolve most of them. However, now I am stuck.
I'm running MAC OS 10.6.8
I have reinstalled Yeoman and Node fixed my paths for (what I know) as global.
Running grunt in my app.
Forces me to run as sudo. (I think this is because this OS has password protected permissions for apps and programs to install/modify files.
** If I run grunt -f
Warning: Unable to write "dist/scripts/vendor/modernizr.js" file (Error code: EACCES). This error happens with most of the main tasks in grunt.
Running sudo grunt
grunt runs through the tasks just fine until the real issue I cannot locate an answer.
Running "modernizr" task
Enabled Extras
shiv
load
cssclasses
Looking for Modernizr references
in dist/styles/main.css
svg
input
Downloading source files
cache modernizr.load.1.5.4.js
And grunt will not finish this download of source files. When I ran grunt using force it would complete the download. I am looking for a solution for the 2nd list item. Any assistance would be helpful.
Found out that there some glitch in the npm grunt-modernizr.
I used this code:
npm remove grunt-moderizr && npm install --save-dev grunt-modernizr
found here: https://github.com/Modernizr/grunt-modernizr/issues/48

Error code: 800A1391 Source: Microsoft JScript runtime error Running Grunt - Module is undefined

New Grunt user here who is using a lot of new tools (npm nodejs) today.
I've got Grunt "installed" and have been able to create a grunt.js file using the init task as described here: http://net.tutsplus.com/tutorials/javascript-ajax/meeting-grunt-the-build-tool-for-javascript/ and here: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md. But whenever I run the "grunt" command I get an error:
Windows Script Host
Script: c:\users\[]\Documents\code\grunt\grunt.js
Line: 2
Char: 1
Error: 'module' is undefined
Code: 800A1391
Source: Microsoft JScript runtime error
As explained in the FAQ, you need to type grunt.cmd instead on Windows because the OS tries to launch grunt.js
Or you can install grunt-cli globally instead. This package will run any version of Grunt if it's been installed locally to your project.
SOLVED !!
So, this problem occur because windows by default associative < *.js > files
with >>
"Microsoft Windows Based Script Host".
grunt need to open by default with (grunt.cmd).
it easy to slove, by change default app (open with..)
Guide :
Go to any javascript file with "js" extension. (any file)
Right-Click(mouse) > Properties > "Opens with:" Change...(button)
Choose Notepad ( or any javascript IDE ).
PROBLEM SOLVED ! :)
good luck
If you're getting a "Microsoft JScript runtime error" that means that node.js isn't even getting invoked; instead Windows Script Host is trying to run your code. That's probably a problem with filetype associations; IIRC Windows defaults to trying to execute a ".js" file with WSH. You may wind up having to create a shortcut to your script, specifying a command line (probably something like "node %1") and a starting directory in order to make sure that it's executed properly.
It would help if you could tell us exactly how you're trying to invoke your code.
it seems that in the latest versions of the grunt modules, you would have to do the following to have it work under windows:
remove any globally installed grunt
npm uninstall -g grunt
install grunt-cli globally
npm install -g grunt-cli
install grunt locally into your project
npm install grunt
installing grunt (v0.4.x) globally does not seem to create the necessary grunt.cmd anymore. it seems that the recommendation is now to have grunt installed locally to be able to use version-specific Gruntfiles
As Florian F suggested, running grunt.cmd works. This is because of the process Windows is looking for your grunt command.
When typing grunt -h Windows will proceed to look for the following files:
./grunt.cmd
./grunt.* (grunt.js is found in this case which is why you see "module is undefined")
%APPDATA%/npm/grunt.cmd
An alternative to using "grunt.cmd" is to use grunter which simply renames the command to grunter... then you no longer have this problem.
To answer this, first we need to understand that the error is caused because it is being executed by Windows Script Host.
Now, run the code from your cmd promt with the following syntax:
>node <application_name>.js
this will allow the Node.js application to open through V8 JavaScript engine(Google's).
P.S: Please reply back if this has helped in resolving your issue else post the problem you are facing after trying this.
I had a similar issue, the problem is file association, I would recommend:
right click on a .js file and choose open with.
then you choose nodejs/node.exe (somewhere in "program files" folder
then make tick box where it says "always open .js files " (paraphrasing)
That should do the trick.
I went through the same issue when running an old Node project.
The issue was with the name of the js file, it was node.js. So the while running the command node node.js, it was opening up a windows dialogue box.
I just changed the name of the file to app.js and the error flew away.
So, in my case i had tryed all the mentioned above with no result.
But i have fund that im dont type: node in the full sentence as the following snipet
node script.js.And remember never understimate your own miscoding.
Solution:
Go to any javascript file with "js" extension. (any file)
Right-Click(mouse) > Properties > "Opens with:" Change...(button)
Choose Notepad ( or any Javascript IDE like VS Code ).

Resources