Shoutem/React-Native Error: 'jest-haste-map: #providesModule naming collision' - xcode

I am using Shoutem and have tried running 'react-native run-ios' and running the xcode workspace file directly. Using both gives this error (I realize Restaurants is misspelled):
Loading dependency graph...(node:22499) UnhandledPromiseRejectionWarning: Error: jest-haste-map: #providesModule naming collision:
Duplicate module name: user.resturants
Paths: /Users/USERNAME/Resturaunts/user.resturants/server/package.json collides with /Users/USERNAME/Resturaunts/user.resturants/app/package.json
This error is caused by a #providesModule declaration with the same name across two different files.
at setModule (/Users/USERNAME/Resturaunts/node_modules/jest-haste-map/build/index.js:446:17)
at workerReply (/Users/USERNAME/Resturaunts/node_modules/jest-haste-map/build/index.js:496:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:19894) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:19894) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
error: bundling failed: Error: jest-haste-map: #providesModule naming collision:
Duplicate module name: user.resturants
Paths: /Users/USERNAME/Resturaunts/user.resturants/server/package.json collides with /Users/USERNAME/Resturaunts/user.resturants/app/package.json
This error is caused by a #providesModule declaration with the same name across two different files.
at setModule (/Users/USERNAME/Resturaunts/node_modules/jest-haste-map/build/index.js:446:17)
at workerReply (/Users/USERNAME/Resturaunts/node_modules/jest-haste-map/build/index.js:496:9)
at process._tickCallback (internal/process/next_tick.js:68:7)
BUNDLE [ios, dev] ../../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.
I have tried following the steps shown here and I still run into the same problem.
Using 'react-native run-ios' also shows this error in the terminal. I am unsure if this is related.
The following commands produced analyzer issues:
Analyze /Users/USERNAME/Resturaunts/node_modules/react-native/React/Base/RCTModuleMethod.mm normal x86_64
Analyze /Users/USERNAME/Resturaunts/node_modules/react-native/React/Base/RCTUtils.m normal x86_64
(2 commands with analyzer issues)
Installing build/Build/Products/Debug-iphonesimulator/Resturaunts.app
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=164):
Unable to lookup in current state: Shutdown
Launching com.shoutem.ShoutemApp
An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=164):
Unable to lookup in current state: Shutdown
The build does succeed but the simulator shows nothing. I have also tried this solution here. I don't have enough experience to know what is going on. I have been trying to get this thing to work for a while now. This is the closest I have ever gotten to a working build.
Here is my package.json:
{
"name": "#shoutem/platform",
"version": "1.7.1-rc.0",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"setup": "cd scripts && yarn install",
"lint": "eslint .",
"configure": "node scripts/configure",
"bundle": "node scripts/bundle",
"build": "node scripts/build"
},
"dependencies": {
"#shoutem/animation": "~0.12.2",
"#shoutem/core": "0.2.5",
"#shoutem/redux-composers": "0.1.4",
"#shoutem/redux-io": "3.0.1-beta.3",
"#shoutem/theme": "~0.11.2",
"#shoutem/ui": "0.23.6",
"#shoutem/ui-addons": "0.0.29",
"babel-preset-es2015": "~6.24.1",
"es6-symbol": "3.1.1",
"lodash": "~4.17.4",
"moment": "2.22.2",
"prop-types": "15.6.0",
"react": "16.4.1",
"react-native": "0.56.0",
"react-redux": "~5.0.2",
"redux": "~3.6.0",
"redux-action-buffer": "~1.0.1",
"redux-api-middleware": "2.0.1",
"redux-logger": "2.6.1",
"redux-persist": "4.1.0",
"redux-thunk": "~2.0.0",
"whatwg-fetch": "1.0.0",
"user.resturants": "https://extensions.static.shoutem.com/user/resturants/0.0.1/app.tgz?timestamp=1540222210009",
"shoutem.about": "https://extensions.static.shoutem.com/shoutem/about/1.7.1/app.tgz?timestamp=1532019904679",
"shoutem.analytics": "https://extensions.static.shoutem.com/shoutem/analytics/1.7.0/app.tgz?timestamp=1531924714589",
"shoutem.application": "https://extensions.static.shoutem.com/shoutem/application/1.7.0/app.tgz?timestamp=1531924719204",
"shoutem.auth": "https://extensions.static.shoutem.com/shoutem/auth/1.7.1/app.tgz?timestamp=1533647965562",
"shoutem.books": "https://extensions.static.shoutem.com/shoutem/books/1.7.0/app.tgz?timestamp=1531924805228",
"shoutem.camera": "https://extensions.static.shoutem.com/shoutem/camera/1.7.1/app.tgz?timestamp=1532513463813",
"shoutem.cms": "https://extensions.static.shoutem.com/shoutem/cms/1.7.0/app.tgz?timestamp=1531924864035",
"shoutem.code-push": "https://extensions.static.shoutem.com/shoutem/code-push/1.7.0/app.tgz?timestamp=1531924869983",
"shoutem.deals": "https://extensions.static.shoutem.com/shoutem/deals/1.7.2/app.tgz?timestamp=1531930828925",
"shoutem.events": "https://extensions.static.shoutem.com/shoutem/events/1.7.1/app.tgz?timestamp=1532513603690",
"shoutem.favorites": "https://extensions.static.shoutem.com/shoutem/favorites/1.7.1/app.tgz?timestamp=1531924890654",
"shoutem.flurry-analytics": "https://extensions.static.shoutem.com/shoutem/flurry-analytics/1.7.0/app.tgz?timestamp=1531925003203",
"shoutem.google-analytics": "https://extensions.static.shoutem.com/shoutem/google-analytics/1.7.0/app.tgz?timestamp=1531925048071",
"shoutem.i18n": "https://extensions.static.shoutem.com/shoutem/i18n/1.7.0/app.tgz?timestamp=1531926118452",
"shoutem.ical-events": "https://extensions.static.shoutem.com/shoutem/ical-events/1.7.1/app.tgz?timestamp=1532513791098",
"shoutem.layouts": "https://extensions.static.shoutem.com/shoutem/layouts/1.7.0/app.tgz?timestamp=1531925159116",
"shoutem.loyalty": "https://extensions.static.shoutem.com/shoutem/loyalty/1.7.7/app.tgz?timestamp=1534422589121",
"shoutem.menu": "https://extensions.static.shoutem.com/shoutem/menu/1.7.0/app.tgz?timestamp=1531925240759",
"shoutem.navigation": "https://extensions.static.shoutem.com/shoutem/navigation/1.7.1/app.tgz?timestamp=1534422615806",
"shoutem.news": "https://extensions.static.shoutem.com/shoutem/news/1.7.0/app.tgz?timestamp=1531925281565",
"shoutem.notification-center": "https://extensions.static.shoutem.com/shoutem/notification-center/1.7.0/app.tgz?timestamp=1531925287012",
"shoutem.page": "https://extensions.static.shoutem.com/shoutem/page/1.7.0/app.tgz?timestamp=1531925310994",
"shoutem.people": "https://extensions.static.shoutem.com/shoutem/people/1.7.0/app.tgz?timestamp=1531925316211",
"shoutem.persist": "https://extensions.static.shoutem.com/shoutem/persist/1.7.0/app.tgz?timestamp=1531925320758",
"shoutem.photos": "https://extensions.static.shoutem.com/shoutem/photos/1.7.0/app.tgz?timestamp=1531925325437",
"shoutem.places": "https://extensions.static.shoutem.com/shoutem/places/1.7.0/app.tgz?timestamp=1531925330220",
"shoutem.platform-analytics": "https://extensions.static.shoutem.com/shoutem/platform-analytics/1.7.0/app.tgz?timestamp=1531925334766",
"shoutem.preview": "https://extensions.static.shoutem.com/shoutem/preview/1.7.0/app.tgz?timestamp=1531925340045",
"shoutem.products": "https://extensions.static.shoutem.com/shoutem/products/1.7.0/app.tgz?timestamp=1531925346246",
"shoutem.push-notifications": "https://extensions.static.shoutem.com/shoutem/push-notifications/1.7.0/app.tgz?timestamp=1531925350876",
"shoutem.rss": "https://extensions.static.shoutem.com/shoutem/rss/1.7.0/app.tgz?timestamp=1531925392345",
"shoutem.rss-news": "https://extensions.static.shoutem.com/shoutem/rss-news/1.7.0/app.tgz?timestamp=1531925397913",
"shoutem.rss-photos": "https://extensions.static.shoutem.com/shoutem/rss-photos/1.7.0/app.tgz?timestamp=1531925402877",
"shoutem.rss-videos": "https://extensions.static.shoutem.com/shoutem/rss-videos/1.7.0/app.tgz?timestamp=1531925407618",
"shoutem.rubicon-theme": "https://extensions.static.shoutem.com/shoutem/rubicon-theme/1.7.2/app.tgz?timestamp=1534422920061",
"shoutem.shopify": "https://extensions.static.shoutem.com/shoutem/shopify/1.7.0/app.tgz?timestamp=1531925522991",
"shoutem.social": "https://extensions.static.shoutem.com/shoutem/social/1.7.0/app.tgz?timestamp=1531925590399",
"shoutem.sub-navigation": "https://extensions.static.shoutem.com/shoutem/sub-navigation/1.7.1/app.tgz?timestamp=1534423025262",
"shoutem.theme": "https://extensions.static.shoutem.com/shoutem/theme/1.7.0/app.tgz?timestamp=1531925600521",
"shoutem.video": "https://extensions.static.shoutem.com/shoutem/video/1.7.0/app.tgz?timestamp=1531925610624",
"shoutem.vimeo": "https://extensions.static.shoutem.com/shoutem/vimeo/1.7.0/app.tgz?timestamp=1531925661052",
"shoutem.web-view": "https://extensions.static.shoutem.com/shoutem/web-view/1.7.2/app.tgz?timestamp=1531925714059",
"shoutem.wordpress": "https://extensions.static.shoutem.com/shoutem/wordpress/1.7.0/app.tgz?timestamp=1531925779176",
"shoutem.youtube": "https://extensions.static.shoutem.com/shoutem/youtube/1.7.0/app.tgz?timestamp=1531925850488"
},
"devDependencies": {
"#shoutem/build-tools": "file:scripts/helpers",
"babel": "~6.3.26",
"babel-eslint": "~6.0.4",
"babel-jest": "23.2.0",
"babel-plugin-transform-decorators-legacy": "~1.3.4",
"babel-preset-react-native": "^5.0.1",
"eslint": "~2.9.0",
"eslint-config-airbnb": "~8.0.0",
"eslint-plugin-import": "~1.6.1",
"eslint-plugin-jsx-a11y": "~1.0.4",
"eslint-plugin-react": "~5.0.1",
"eslint-plugin-react-native": "~1.0.2",
"jest": "23.1.0",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!react-native|#shoutem/theme|#shoutem/animation|#shoutem/ui)"
]
}
}
You are able to reproduce this by following the shoutem tutorial . I stopped at the linked part (setting local environment). I also got an error when running 'react-native run-ios' but solved it by following this

Related

Jest not handling errors from expect() in subscribe() of RxJS observable

I've been trying to get Jest working with RxJS and am having trouble with Jest not propagating errors from inside the subscribe callback.
Here is a sample test I've tried that is not working:
import {of} from 'rxjs';
test('should fail', () => {
of(false).subscribe(val => {
expect(val).toBe(true);
});
});
The above test should fail, but it passes. I've googled around and found the following solution:
Failing expect() inside subscribe() does not mark test as invalid
This suggests using the "done" syntax in jest to solve the issue. While using the "done" callback does get the above test to fail, there are a number of issues with this approach:
Undescriptive errors
The test fails because the 'expect' call in subcribe() throws an error, resulting in 'done()' never getting called. The test then times out, waiting for done. So instead of propagating the 'expect' error, it is causing a timeout error, which means every test that fails in the expect clause will show a timeout error instead of the actual error message of the failed 'expect' call.
Tests take longer to fail
Because all tests are failing due to a timeout error, that means it takes 5 seconds for each test to fail (async tests timeout after 5 seconds). This can dramatically increase the amount of time for tests to run
Poor use of done
The done callback is meant to support asynchronous use cases for testing. But rxjs is not necessarily asynchronous. The code I inlined above actually runs synchronously. For example, the following test will pass:
import {of} from 'rxjs';
test('should pass', () => {
let didRunSynchronously = false;
of(true).subscribe(() => {
didRunSynchronously = true;
});
expect(didRunSynchronously).toBe(true);
});
It seems strange to have to use asynchronous semantics to solve a problem for a synchronous test.
Wondering if anyone has come up with a good solution for testing in rxjs that will result in the expect calls to properly get handled by the testing library.
Thanks in advance!
Relevant dependencies in package.json:
"dependencies": {
"#babel/polyfill": "^7.0.0",
"classnames": "^2.2.6",
"history": "^4.7.2",
"json-stringify-pretty-compact": "^1.2.0",
"minimist": "^1.2.0",
"normalize.css": "^8.0.0",
"nullthrows": "^1.1.0",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-router-dom": "^4.3.1",
"rxjs": "^6.3.3",
},
"devDependencies": {
"#babel/core": "^7.2.2",
"#babel/plugin-proposal-class-properties": "^7.1.0",
"#babel/plugin-proposal-object-rest-spread": "^7.0.0",
"#babel/preset-env": "^7.1.0",
"#babel/preset-flow": "^7.0.0",
"#babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-env": "^2.4.1",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"copy-webpack-plugin": "^4.5.3",
"css-loader": "^1.0.0",
"eslint": "^5.9.0",
"eslint-plugin-flowtype": "^3.2.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.11.1",
"eslint-watch": "^4.0.2",
"flow-bin": "^0.83.0",
"html-webpack-plugin": "^3.2.0",
"jest": "^23.6.0",
"prettier": "^1.15.3",
"style-loader": "^0.23.1",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9"
}
.babelrc file
{
"plugins": [
"module:#babel/plugin-proposal-class-properties",
"module:#babel/plugin-proposal-object-rest-spread"
],
"presets": [
["module:#babel/preset-env", { "targets": { "node": "6.10" } }],
"module:#babel/preset-flow"
]
}
Even if i am some years later on this topic, this might help others that are new to testing async code.
Please refer for example to https://jestjs.io/docs/asynchronous and use a done() callback at the end of your subscription.
If this callback is not executed, because of the error before, the test will fail as expected.
it('should fetch the right data', done => {
fetchData().subscribe(data => {
expect(data).toBe('expected data');
done();
});
});
Figured out the problem! Leaving this here for anyone who runs into a similar issue. RxJS and Jest were working properly and propagating the errors correctly. The problem was that I added a "jest.useFakeTimers" call to the testing script. For some reason, this was causing the errors not to propagating properly in the test. I needed to add "jest.runAllTimers" to get the errors to throw. Here is the full test script, implemented correctly:
import {of} from 'rxjs';
jest.useFakeTimers();
test('should fail', () => {
of(false).subscribe(val => {
expect(val).toBe(true);
});
jest.runAllTimers();
});
If you don't need mock timers, then no need to add them. I thought it was a bit strange that fake timers were an issue even though I could verify the code was getting called synchronously. If someone has more insight on the implementation details of why this is the case, I'd appreciate some explanation.

Error when using Nativescript's RadSideDrawer

I am trying to add the nativescript-telerik-ui and use the side drawer in a blank project. The project builds properly, but I am getting the error shown below if I try to run the code on a connected device:
The project was running correctly until I tried to use the drawer on one of the pages.
Here is my package.json:
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.drawertest",
"tns-android": {
"version": "2.4.1"
}
},
"dependencies": {
"nativescript-telerik-ui": "^1.5.1",
"nativescript-theme-core": "^0.2.1",
"tns-core-modules": "2.4.4"
},
"devDependencies": {
"babel-traverse": "6.21.0",
"babel-types": "6.21.0",
"babylon": "6.14.1",
"lazy": "1.0.11",
"nativescript-dev-android-snapshot": "^0.*.*"
}
}
I also tried running it in Genymotion. Here is the error I am getting there:
An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.drawertest/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onCreate failed
Error: Building UI from XML. #file:///app/main-page.xml:20:5
> Module 'ui/rad-side-drawer' not found for element 'RadSideDrawer'.
> com.tns.NativeScriptException: Failed to find module: "ui/rad-side-drawer", relative to: app/tns_modules/
com.tns.Module.resolvePathHelper(Module.java:159)
com.tns.Module.resolvePath(Module.java:60)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1022)
com.tns.Runtime.callJSMethodImpl(Runtime.java:907)
com.tns.Runtime.callJSMethod(Runtime.java:895)
com.tns.Runtime.callJSMethod(Runtime.java:879)
com.tns.Runtime.callJSMethod(Runtime.java:871)
com.tns.NativeScriptActivity.onCreate(android.app.Activity.java)
android.app.Activity.performCreate(
I should probably mention that I getting similar error when I am trying to run the same code on my mac using the ios emulator.
What am I missing?
Thank you.
EDIT: It turns out I had a syntax error. Once corrected, everything worked as expected.
From the error log it looks like you have declared an incorrect namespace for the RadSideDrawer component ("ui/rad-side-drawer"). That component is part of the nativescript-telerik-ui plugin which can be found in the nativescript-telerik-ui-pro/sidedrawer module in the node_modules folder.
For more details you can take a look at the official documentation here.
Simply declare this namespace and use it when declaring the RadSideDrawer in the XML:
xmlns:drawer="nativescript-telerik-ui-pro/sidedrawer"

Unable to use Elixir after upgrade

I upgraded my Elixir version from 3.0 to 5.0. The npm update command runs fine but when I try to run gulp --production it fails.
I have given the error below which I get.
My package.json file (which should be identical to the one at https://github.com/laravel/laravel/blob/master/package.json)
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"gulp": "^3.9.1",
"laravel-elixir": "^5.0.0",
"bootstrap-sass": "^3.3.0"
}
}
When running gulp --production I get the below error
/home/vagrant/Code/laravel/node_modules/laravel- elixir/node_modules/gulp- cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:157
this.processing = new Promise(function (resolve, reject) {
^
ReferenceError: Promise is not defined
at LazyResult.async (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:157:31)
at LazyResult.then (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/node_modules/cssnano/node_modules/postcss/lib/lazy-result.js:79:21)
at Transform.stream._transform (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-cssnano/index.js:27:17)
at Transform._read (_stream_transform.js:179:10)
at Transform._write (_stream_transform.js:167:12)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Transform.Writable.write (_stream_writable.js:183:11)
at write (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
at flow (/home/vagrant/Code/laravel/node_modules/laravel-elixir/node_modules/gulp-concat/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
You need to upgrade Node also.
You can read here how it can be updated upgraded: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version

Syntax error occurs with cli node/coffeescript app installed globally via npm

I have a cli app written in coffee-script. The cli app uses commander (https://github.com/tj/commander.js) to take arguments. I have three files in my bin dir:
mediatidy
mediatidy-config
mediatidy-media
If I run bin/mediatidy in the project folder in bash commander executes fine. If I type bin/mediatidy config or bin/mediatidy media in bash commander also executes fine and is waiting for an <action>.
The odd thing is I published the project to npm and get different results when installed globally. If I install the project via sudo npm mediatidy -g (I am using Mac OSX 10.10) I can see the following files in /usr/local/bin/:
mediatidy
mediatidy-config
mediatidy-media
If I run bin/mediatidy in the project folder in bash commander executes fine. If I type bin/mediatidy config or bin/mediatidy media in bash I get the following error:
mediatidy config
/usr/local/lib/node_modules/mediatidy/bin/mediatidy-config:3
program = require 'commander'
^^^^^^^^^^^
SyntaxError: Unexpected string
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
Looks like a coffeescript compilation error... wat.
If I run the same command but with the dash, bin/mediatidy-config, it works fine. I have another app that is private that works without having to use the dash that is globally installed. What am I missing here?
edit: added my package.json file:
package.json:
{
"preferGlobal": true,
"main": "index",
"name": "mediatidy",
"description": "Keep your media nice and tidy!",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "git#github.com:tkdan235/mediatidy.git"
},
"engines": {
"node": ">=0.10.0"
},
"directories": {
"bin": "bin",
"lib": "lib"
},
"dependencies": {
"async": "^0.9.0",
"coffee-script": "^1.8.0",
"colors": "^0.6.2",
"commander": "^2.1.0",
"fs-extra": "^0.11.1",
"lodash": "^2.4.1",
"nconf": "^0.7.1",
"node-dir": "^0.1.6",
"node-ffprobe": "^1.2.2",
"prompt": "^0.2.14",
"sqlite3": "^2.2.7"
},
"coffeelintConfig": {
"max_line_length": {
"name": "max_line_length",
"value": 120,
"level": "error",
"limitComments": true
}
}
}
This actually appears to be a limitation of Commander.js. At first glance, it doesn't appear to call the scripts as shell scripts. Instead, it calls them with node which won't be compiling the CoffeeScript code. See https://github.com/tj/commander.js/blob/master/index.js#L447-L479 (line 469 in particular).
Update:
After some further digging, it looks like this WAS once supported and working. The way sub-commands were called was just their script name. Then this pull request broke it: https://github.com/tj/commander.js/pull/173. The last working version for this behavior was in 2.1.0. You could pin your version to 2.1.0 to get this behavior back.

Grunt fails trying to load an empty module

I'm a bit stuck with my Jenkins setup on OSX Lion 10.7.3.
I'm using Grunt in my webapp to run Jasmine tests, build less, create cache manifest etc. Everything works on my laptop Lion 10.7.5, but on the server box grunt fails from time to time with the following error:
$ grunt less
module.js:340
throw err;
^
Error: Cannot find module ''
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:44:3)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at Process._handle.onexit (child_process.js:678:10)
This is intermittent, it fails approximately once out of five runs and is not task specific. It fails with the same rate when running grunt manifest or grunt test.
Once thing I noticed is that when it works it takes a second or two until the task starts executing, but when it fails it fails immediately.
I tried to remove node_modules, npm cache clear, reinstalling grunt-cli. Nothing works.
Here's my package.json:
{
"name": "webapp",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "0.4.0rc7",
"grunt-contrib-copy": "0.4.0rc7",
"grunt-contrib-concat": "0.1.2rc6",
"grunt-contrib-coffee": "0.4.0rc7",
"grunt-contrib-uglify": "0.1.1rc6",
"grunt-contrib-compass": "0.1.1rc8",
"grunt-contrib-jshint": "0.1.1rc6",
"grunt-contrib-mincss": "0.4.0rc7",
"grunt-contrib-connect": "0.1.1rc6",
"grunt-contrib-clean": "0.4.0rc6",
"grunt-contrib-htmlmin": "0.1.1rc7",
"grunt-contrib-imagemin": "0.1.1rc8",
"grunt-contrib-livereload": "0.1.0rc8",
"grunt-contrib-jasmine": "~0.3.2",
"grunt-contrib-less": "0.5.0",
"grunt-manifest": "0.4.0",
"grunt-jslint": "0.2.5",
"grunt-bower-hooks": "~0.2.0",
"grunt-usemin": "~0.1.7",
"grunt-regarde": "~0.1.1",
"grunt-requirejs": "~0.3.1",
"grunt-mocha": "~0.2.2",
"grunt-open": "~0.1.0",
"matchdep": "~0.1.1"
},
"engines": {
"node": ">=0.8.0"
}
}
npm and node versions:
$ npm -version
1.2.11
$ node --version
v0.8.20
I have now stripped down both packages.json and Gruntile.js:
$ cat package.json
{
"name": "webapp",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"grunt": "0.4.0rc7",
"grunt-manifest": "0.4.0",
"matchdep": "~0.1.1"
},
"engines": {
"node": ">=0.8.0"
}
}
$ cat Gruntfile.js
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
manifest: {
generate: {
options: {
basePath: 'app/',
exclude: ['js/lib/amp/com.vaultus.api.WebApiAggregated.cache.js', 'js/lib/amp/com.vaultus.api.DebugWebApiAggregated.cache.js'],
timestamp: true
},
src: [
'index-hybrid.html',
'*.xml',
'js/**/*.js',
'css/**/*.css',
'css/images/**/*',
'i18n/**/*.js',
'template/**/*.html'
],
dest: 'app/cache-manifest.mf'
}
}
});
grunt.registerTask('build', [
'manifest'
]);
grunt.registerTask('default', ['build']);
};
No luck :(
We were hitting this issue on our CI builds.
After a bit of digging it looks like this was a bug in grunt-cli 0.1.6 and has been fixed in 0.1.7 of grunt-cli.

Resources