Strange gulp "Directory does not exist" error? - gulp

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.

Related

Module not found: Can't resolve 'react-avatar'

I am having a MERN website with 2 folders in the Github repo, client and backend. When I am turning on the react server the output page is showing an error as
Failed to compile
./src/components/Student/Student.jsx
Module not found: Can't resolve 'react-avatar' in '/MernCrudApp/client/src/components/Student'
This error occurred during the build time and cannot be dismissed.
To reproduce this error please follow the following steps.
Clone the repo
Go into the backend folder and write npm install in the terminal and then npm run start, and then enter the client folder and repeat the commands respectively.
There is no 'react-avatar' package in your client's package.json.
npm install react-package in this folder and you should be good.

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

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

DiscordJS, Gulp reload bot on file save?

I just started messing around with Discordjs and I'm working on just a super simple bot example, but the most annoying thing is whenever I make any changes I need to stop the bot in command line and execute the command to come back online in order for any of my code changes to take affect. Is there any way to automate this process? lets say I make a change to bot.js, would there be a way for something like gulp to detect this and restart the bot?
You could use something like nodemon (http://nodemon.io/).
Install it by running: npm install -g nodemon. This will install it globally on your computer. Then just run nodemon on the console instead of node myfilehere.js.
Make sure the file you are running with node myfilehere.js is the same name on package.json under "main"

json file location in command prompt

I am trying angularjs-2 for the first time from the example found here
and everything was working fine until I came to a point where the author has written something like this
Now open the package.json file location in command prompt and execute
the below command to load the required modules and supported files
which are mentioned in the package.json file.
npm start
after reading this I open command prompt by pressing window+R and write cmd
and I enter the following path
E:....\nodejs with angular2 testing\nodejs with
angularjs2\nodejs with angularjs2\
but i am not able to do anything after this point
how can i execute the package from command prompt,?
i tried the same with developer command promt but facing the same issue,
hey guys i know i am bad in english but please i need help here
First you need to have nodejs in your system.
If you don't have nodejs, then download it. which shifts npm with it. [It is similar kind of stuff what nuget does in VisualStudio.]
As you mentioned package.json is already there in your project then you need to got to you Application folder in command prompt to install packages by running npm install.
For example : If your App folder is in E:\Project\Myangular2App,
then after opening Command Prompt with window+R, navigate to E drive by E:, then navigate to your App folder by cd Project\Myangular2App and run npm install. This will install all the packages mentioned in package.json
start seems to be a script configured in your package.json which probably runs something else.
Please state if npm (the node package manager) runs on your CLI without any argument. If not you have to get npm working first. It has to be in your $PATH variable in order to function anywhere.

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"