Grunt assemble - strange 'module not found' issue - node.js

I'm adapting an existing project to use Grunt, Assemble and other workflow tools. I have the workflow working on one machine, but when I try to run the Gruntfile on a different system I get an error:
[/home/ian/workspace/myproject] (master)
ian#ian-desktop $ grunt assemble
Running "assemble:pages" (assemble) task
Warning: Cannot find module '/home/ian/workspace/myproject/node_modules/
grunt-assemble/node_modules/assemble/node_modules/handlebars-helpers/
lib/helpers/home/ian/workspace/myproject/node_modules/grunt-assemble/
node_modules/assemble/node_modules/handlebars-helpers/lib/helpers/code.js'
Use --force to continue.
Aborted due to warnings.
The path that Grunt is trying to load is completely messed up (note the re-occurrence of the cwd about halfway through), but the filename it's looking for - code.js - is installed locally (by npm -i):
[/home/ian/workspace/myproject] (master)
ian#ian-desktop $ find . -name code.js
./node_modules/grunt-assemble/node_modules/assemble/node_modules/
handlebars-helpers/node_modules/remarkable/lib/rules_block/code.js
./node_modules/grunt-assemble/node_modules/assemble/node_modules/
handlebars-helpers/test/code.js
./node_modules/grunt-assemble/node_modules/assemble/node_modules/
handlebars-helpers/lib/helpers/code.js
./node_modules/grunt-mocha/node_modules/mocha/node_modules/jade/
lib/nodes/code.js
Both the systems I'm working on are Ubuntu 14.10, so shouldn't differ in any material way. Node -v gives v0.10.33, npm -v gives 2.1.5. I've tried:
checking out a fresh copy of the entire project from git
clearing all Bash environment vars before running Grunt
I'm having a hard time figuring out what's at the root of the different behaviour of the same code on two similar machines. Other tasks in my Gruntfile seem to be working fine, it's just the assemble task that's broken. Suggestions of where to look, or debug techniques to try, would be very welcome!

Related

Grunt "aborted due to warnings" when too much output is generated

I work on a NodeJS project and I use grunt as task manager. In particular, I use grunt to run unit test and generate coverage reports.
The program under test has a configurable feature that allows to generate more or less output in the log (the typical ERROR/WARN/DEBUG selector). I have observed that if I run unit test with grunt with maximum logging verbosity (DEBUG) grunt coverage ends with:
Aborted due to warnings.
However, same grunt command with a less verbose log level (i.e. without touching a single line of code expect the log level configuration) works without problem and I get:
Done, without errors.
Has grunt some kind of "output limit" which when overpassed causes an abort situation? Can that limit be removed or configured anyway?
I'm using istanbul for code coverage. Version information follows (in the case they are useful):
$ node --version
v6.12.3
$ npm --version
3.10.10
$ grunt --version
grunt-cli v1.2.0
grunt v0.4.5
$ cat node_modules/istanbul/package.json | grep version
"version": "0.1.46"
(I'm new to grunt so sorry if I'm asking a silly question :)

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.

Grunt only runs default task

Using OSX Maveriks, iTerminal, zsh.
Problem: Grunt runs only the default task regardless of the task you specify.
Problem: It only happens in 1 computer.
What can be the reason for grunt not to run but the default task. I've been working with Grunt for a long time now and we use it at the company I work at. Everything has been working perfectly smooth except for 1 single coworker that when he runs grunt myTask is like if he were running just grunt, even if I run a made up task like grunt myNotExistentTask it ignores it and again looks like it runs grunt.
I did check for stupid errors:
Checked that I'm accessing the same project folder (multiple times).
I deleted the default task to see if it complained and it does.
I checked that the Gruntfile was not throwing errors. Then I forced to throw errors to see if it would complain, and it does.
Runned npm install.
Check both bashrc and zshrc for a grunt command or something.
Obviously grunt is accessible.
Runned it in the default terminal and in iTerm.
"Have you try to turn it on and off?" Yes I did restar the laptop.
I tried with multiple coworkers laptops and it only happens in the one laptop.
I did not have time to (but I will check for these):
test creating a simple Gruntfile somewhere else in his laptop, but I have a weird feeling that it would behave the same way.
reinstall grunt. Would that help?
grunt --version or others for that matter, I assumed that it has the specified version in the package.json.
we are using:
"grunt-cli": "^0.1.13",
"grunt": "^0.4.4"
The code is not causing the issue here because every computer runs it but one. I can't show the actual code but I can give you the boilerplate just in case there is some mysterious thing I don't know about:
module.exports = function(grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
someTask : {
options : {
},
target1 : {
}
}
});
grunt.loadNpmTasks("dependency1");
grunt.loadNpmTasks("dependency2");
grunt.loadNpmTasks("etc");
grunt.registerTask("default", function () {
// creates a server with one of the dependencies
});
grunt.registerTask("w", function () {
// creates a watch with one of the dependencies
});
};
There is a reason behind why we are not simply doing something like grunt.registerTask("default", [".."]). Basically, our projects are too big and we need to change settings for each task to increase performance (e.g. not to watch too many files, etc).
I googled this different ways and couldn't find anything about this happening before. Any ideas are welcomed.
Edit
I forgot to mention that he has been working with the project for a while, we just recently noticed because he never needed to use any other task but the default task until a few days ago when he needed to use a different task, in summary, we don't know when or why it started.
After:
Deleting and cloning the repo.
Deleting npm_modules.
Reinstalling everything.
Creating an isolated project to test this issue.
and failing, we checked for the paths to grunt thanks to a comment by #XavierPriour
Using zsh with iTerm:
➜ folder git:(branch) which grunt
/usr/local/bin/grunt
➜ folder git:(branch) type -a grunt
grunt is /usr/local/bin/grunt
grunt is /usr/bin/grunt
We deleted the extra grunt binary:
➜ folder git:(branch) cd /usr/bin
➜ bin sudo -rm grunt
And everything started working correctly. I assume the issue is he installed grunt globally instead of just grunt-cli, although I'm not sure.
The most popular answer to this question shows the dos and don'ts of how to install grunt.

Cannot find module 'assetmanager'

I'm trying to run the MEAN stack on windows. I've installed all the pre-requisites (I think) but when I try to start the server via the gulp command I get the error:
Error: Cannot find module 'assetmanager'.
IMAGE:
I have tried running npm install assetmanager which run fine but I still get this error.
This is my first time trying to run node on a machine (I should have used a linux box) so go easy on me as I am learning :-).
Any and all help appreciated.
David
I had exactly the same problem on Linux Mint 17.2.
The failing way: This was my first project that I'd generated and I don't think I had all the dependencies installed before I ran the init command (g++ was missing).
I tried the npm install assetmanager command as you did and then install worked. Running gulp after this, it got further but this time I was missing mongoose. I installed that then it couldn't find .../config/env/all so I sylinked the default.js config. Then running gulp again, errorhandler was missing. I figured it shouldn't be this hard so...
The working way: I deleted that failure of a project and init'd a new one and it worked. Unfortunately I'm not sure if the init didn't work the first time but I missed the error/warning or something else caused it. All I can recommend is try creating another project and see if that works.

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

Resources