Gulp bundle --ship: The build failed because a task wrote output to stderr - gulp

I've been getting this error when trying to do a gulp bundle --ship command:
The build failed because a task wrote output to stderr.
Exiting with exit code: 1
I'm pretty new to this so have no idea how to proceed with it. It's happening even when I run through the helloworld webpart now. The gulp serve works and I can bundle and package the solution as long as I don't add a --ship to it. I've written and published apps before on the same machine so I don't know what is different now.
I've uninstalled every extension and re-installed the application but it's still doing it. Any help would be appreciated.

Just for quick win you can use --debug flag for bundling task instead of --ship until this bug will be fixed in future releases:
gulp bundle --debug
gulp package-solution --ship
The bundled file will be bigger, but at least you are not getting "The build failed because a task wrote output to stderr" error in CI/CD.

It normally happens because of the warnings. You can add suppression like mentioned below in gulpfile.js
build.addSuppression(Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.);
build.addSuppression(/Warning/gi);

I got this error because caniuse-lite needed a database update. It was confusing because there was no red error message.
Easy fix: npx browserslist#latest --update-db

Related

How do I fix gulpfile.js to avoid "Did you forget to signal async completion?" when running "gulp ngrok-serve" and DO NOT have the task defined?

I used 2 tutorial clips from Microsoft (first, second) to build a sample Teams Message Extension.
I'm down to the final step of really starting the app with the gulp ngrok-serve command, but I get this error message:
...
[16:05:29] Watching .env
[16:05:29] The following tasks did not complete: ngrok-serve, serve, watch
[16:05:29] Did you forget to signal async completion?
I've read various suggestions on how to fix this, but the problem in my case is that I don't have the "ngrok-serve" task defined in my file. It seems to be running a "default" version of it.
So how should I define/overwrite it, so that I can fix it's implementation, in my gulpfile.js file ?
Thank you.
We were able to run the app successfully using gulp serve, as mentioned in the Build your first Microsoft Teams app using the Yeoman generator documentation. Please run the app using gulp serve.

Aurelia bundle with gulp throws "TypeError: Path must be a string. Received undefined"

I'm using the skeleton-typescript aurelia skeleton-navigation package, when running gulp bundle it gives me an error that says path must be a string but was undefined
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.basename (path.js:801:5)
at exports.writeOutputs (C:\Users\joaoe\Desktop\skeleton-navigation\skeleton-typescript\node_modules\systemjs-builder\lib\output.js:137:23)
at C:\Users\joaoe\Desktop\skeleton-navigation\skeleton-typescript\node_modules\systemjs-builder\lib\builder.js:575:14
at tryCatcher (C:\Users\joaoe\Desktop\skeleton-navigation\skeleton-typescript\node_modules\systemjs-builder\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\joaoe\Desktop\skeleton-navigation\skeleton-typescript\node_modules\systemjs-builder\node_modules\bluebird\js\release\promise.js:502:31)
All gulp related files can be found here since there are more than one.
Even the cloned package throw that.
I'm running Node 6.0.0 and tested with 5.9.1, on Windows 10.
There is some property that I need set to be that path ? Seems related to Aurelia pre built tasks, from comments could also be an environment problem.
As I tracked it down, the issues seems to be an ugly combination of node-gyp, Windows and node 6
So install all dependencies needed for node-gyp, following your OS steps as seen at official repo. Unfortunately for now if you are running Windows is likely that you need to install Visual Studio. Then run npm install on the repository and see if there is any error, should be no one now. Then try to gulp bundle it should work now. With downgraded node to 5.11 I was able to run again, I did not test with node 6 but feel free to try.

Strange gulp "Directory does not exist" error?

I have checked out a repo, run npm install and tried to run Gulp but I get this error:
[16:33:00] Directory "/Users/myname/project/folder/web/js-tasks" does
not exist.
If in the terminal I go cd /Users/myname/project/folder/web/js-tasks then it takes me to that directory with no problem. Ive tried running the gulp task as sudo incase its permission but I get the same result.
The gulpfile.js is at ~project/folder/web. I am on a mac and I am using Vagrant. I am trying to run this from the host machine but if I SSH into my Vagrant machine, cd to where the gulpfile.js is and run gulp log I get a similar error Directory "/web/js-tasks" does not exist.
Many times when I faced problems with gulp scripts - I use WebStorm IDE to debug them.
Fortunately WebStorm have debug feature for gulp tasks.
After you set breakpoint in your gulpfile.js, you need to:
Open Gulp panel in WebStorm
Right click on task you need to debug
Click "Debug ..." in context menu
When debugger stops on breakpoint you can manually check how Gulp "see" your file system by evaluating JS expression fs.readdirSync("/Users/myname/project/folder/web/js-tasks") in "Watches" panel.
It turns out whenever there is any error in the gulp file that stops it running then I get this message instead of a proper error message.

Error running gulp on Windows 10

I'm running Windows 10 build 10576(latest) and I get an error when running gulp from my project root folder(or anywhere). Here's a screenshot of the error: http://puu.sh/l3mLf/522a4e6dbe.png
Error message says "invalid character".
(I've installed gulp globally)
The very first line of gulp.js in the bin folder is the following:
#!/usr/bin/env node
I didn't have this problem before and I'd really want to get this sorted out. Thanks.
I have the same error when try running "node_modules\gulp\bin\gulp.js install".
I found the solution here at Testing out Protractor interactively
Just add "node" command in front of it will work. In my case "node node_modules\gulp\bin\gulp.js install"

Visual Studio 2015 - Where's the gulp task runner?

I heard Mads Kristensen in his videos mention that Gulp and Grunt are both first class citizens. I thought I even heard mention of the Gulp task runner.
But when I create a gulpfile and right click there's no task runner.
Has anyone been able to get the "native" gulp task runner (if there is one) in Visual Studio 2015 Preview to appear?
View > Other Windows > Task Runner Explorer and click refresh
or just Ctrl + Alt + Bkspace
The Preview version of VS2015 requires Gulp to be installed globally and has a few other issues with auto-discovery of the gulpfile.js. These issues will all be addressed by the time VS2015 ships.
I had this same problem with VS2015 - TRX was showing "no tasks found" even though I had a valid, linted, gulpfile.js in the site root. I found the answer here: http://www.roelvanlisdonk.nl/?p=4258
Steps: Close VS. Open a cmd prompt from the site root and run npm install. Re-open VS and you should see your tasks in TRX. It worked for me.
EDIT: I had gulp installed globally but still encountered this "error." The above steps resolved the issue though.
Well I solved the problem with several restarts of VS2015. Finally the task runner appeared for my gulpfile. I still have no idea why it did not appear from the start but it's a preview version so maybe something is not quite right yet.
Barryman9000's answer helped me on the right track. I started with an empty ASP.NET 5 project in VS2015 and had no package.json file at the project root. Running npm install gave me an error message about missing package.json. After adding that file with the default dependencies from another ASP.NET 5 project, the Dependencies started downloading and my gulpfile tasks appeared in the Task Runner Explorer.
In your bash, go to the directory gulpfile.js is installed in and run:
npm install gulp
Why the downvotes? Please read the OP's question and the comments beneath it. Also, note that the answer with, currently, the most points has nothing to do with the question. Also please note that Mads Kristensen himself said that the issue was to install gulp.
Also, as for the commenter "Bonner" of this answer, note that Bash doesn't mean Linux. You can install git bash for Windows and run all of your NPM and Git commands there. Most developers I know use that bash on windows for all npm needs.
Lastly, if your Gulp Task Runner is not working, that is most likely because it is not recognizing your gulpfile. That is due to gulp not being installed. VS2015 didn't always install gulp for you. So the fix was to install gulp globally (As Mads Kristensen said), or directly where your gulpfile is. Also, restarting or re-installing VS sometimes kickstarted the gulp installation if you're lucky.
Conclusion: My answer is the correct answer. I reference the actual OP Question, comments beneath it, Mads Kristensen, and even the accepted answer. Yet, this answer is in the negative and some random answer about how to use the "View" menu in Visual Studio has 40 points.