I have attempted to install Gulp using NPM but the gulp command is not getting recognized. These are the commands I ran. I am using Git Bash and running it as admin. I am using Windows 10.
npm install gulp-cli --global
( Attempt to run 'gulp' and 'gulp -v' and nothing works )
Then navigating to my project folder
npm install gulp --save-dev
( Attempt Gulp command again and it still not recognized )
My env path for npm is C:\Users\ *username* \AppData\Roaming\npm
When I run
npm config get prefix
It returns C:\Program Files\Git\Roaming\npm
I am fairly new to NPM but I have been searching for hours and trying everything. I have uninstalled and reinstalled Node and npm multiple times. Sorry if this has been answered before but every other thread I found did not solve this issue.
Install gulp and gulp-cli globally
npm install --global gulp-cli
npm install --global gulp
npm install gulp -D
Update:
Make sure install gulp locally and globally. After that check status using these command :
npm ls
npm ls -g
After that make sure to link gulp
npm link gulp
And maybe you should check you env.
Create an environmental variable called NODE_PATH
Set it to: %AppData%\npm ( It's you npm path )
Close CMD, and Re-Open to get the new ENV variables
Add gulp to scripts in your package.json file:
"scripts": {
"gulp":"gulp"
},
Then you can use the command:
npm run gulp name of task
Writing function like this worked for me:
gulp.task('message', async ( ) => {
console.log('gulp task is working ')
})
This worked for me:
npm config delete prefix
Related
I can't install gulp globally on my windows 7 machine. I used npm install --global gulp-cli but showed this error:
when i used gulp -v I got this error
please help
At least, It solved! I followed this article install gulp till step #2 then I installed gulp globally on terminal using this code npm install gulp-cli -g.
Thank you everyone for help me.
try this commands:
If you've previously installed gulp globally, try to delete it using:
npm rm --global gulp
After that install new version of gulp using:
npm install --global gulp
npm link gulp
and verify yourgulp version:
gulp --version
I am trying to start my angular app using grunt serve command
but I am getting Fatal error: spawn cmd ENOENT.
I used following commands to generate my Angular App
npm install -g yo grunt-cli bower
npm install -g generator-angular
yo angular
npm install
bower install
then i used grunt serve command to start my app
but its not working.
System Info:
OS: Windows 7 64 bit
npm version : 2.11.3
please help me, I gone through all the grunt documentation but no clue.
Try the following possible solutions:
Verify the npm folder exists at the following location C:\Users\My-UserName\AppData\Roaming\npm
Try to run npm cache clean
Add C:\Windows\System32\ to the PATH Environment variable
Run grunt serve with cmd.exe instead of git bash. I have the same problem and have dealt with it in this way.
I installed gulp following the standard procedure:
$ npm install --global gulp-cli
adding the project dev dependency
$ npm install --save-dev gulp
and a gulpfile.js
When running gulp from Git Bash I get the error gulp: command not found
I followed related threads here on SO updating my path variable (Windows 7) with C:\Users\username\AppData\Roaming\npm to no avail
I actually didn't find any gulp folders inside C:\Users\username\AppData\Roaming\npm (other packages are still there and function as expected). Instead, gulp seems to get installed to C:\Program Files\Git\usr\local
Running npm root and npm root -g respectively, return
C:\Users\username\node_modules and
C:\Program Files\Git\usr\local\node_modules
I also got the following warnings when running npm install --save-dev gulp
I feel like I mixed up paths somehow, but I'm a bit lost, as I'm new to Node and Gulp.
After open command shell with administrator simply write npm install -g gulp and npm install -g gulp-cli. You can reach from every location to gulp then.
sudo npm install gulp-cli -g
npm init
npm install gulp --save-dev
npm install browser-sync --save-dev // I added this file later, read documentation
I checked package.json which shows gulp too.
made gulp.js file as per documentation
Gulp is installed checked, npm ls. please find screen shot below
https://i.stack.imgur.com/cn3w1.png
Please check below screenshot for gulp error
https://i.stack.imgur.com/VeAns.png
How to use nodejs to build a cross platform project?
I develop on Windows, but my codebase builds on a Linux-based CI server. It uses Grunt to build the frontend, and requires several nodejs modules for that.
Nodejs requires modules to be installed locally to the project in order for the to be loaded by grunt.task.loadNpmTasks. The issue with that is that I have to install them from somewhere, either Windows or Linux, and when I do from one it doesn't work on the other.
The list modules my project require are installed locally as follows:
npm install connect-livereload --production
npm install time-grunt --production
npm install load-grunt-tasks --production
npm install jshint-stylish --production
npm install load-grunt-tasks --production
npm install grunt-contrib-copy --production
npm install grunt-contrib-concat --production
npm install grunt-contrib-uglify --production
npm install grunt-contrib-compass --production
npm install grunt-contrib-jshint --production
npm install grunt-contrib-cssmin --production
npm install grunt-contrib-connect --production
npm install grunt-contrib-clean --production
npm install grunt-contrib-htmlmin --production
npm install grunt-contrib-imagemin --production
npm install grunt-contrib-watch --production
npm install grunt-rev --production
npm install grunt-usemin --production
npm install grunt-mocha --production
npm install grunt-exec --production
npm install grunt-open --production
npm install grunt-svgmin --production
npm install grunt-concurrent --production
npm install grunt-ember-templates --production
npm install grunt-replace --production
npm install grunt-neuter --production
If I install it from Windows and then run grunt on the project folder from Windows still it all works perfectly. If I then check the code into git and build in the linux box, chmod 777 and chown to my user, and run the same grunt command. It fails with a lot of errors like these:
Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html
Fatal error: spawn ENOENT
I ran npm install and it starts failing with another message:
Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html
/home/administrator/platform/frontend/node_modules/grunt-contrib-compass/node_modules/tmp/lib/tmp.js:261
throw err;
^
Error: spawn ENOENT
at errnoException (child_process.js:998:11)
at Process.ChildProcess._handle.onexit (child_process.js:789:34)
Nothing I do makes it work.
So from the Linux box I deleted the whole node_modules directory from my project and rerun the install commands above. All works perfectly on Linux now.
Then I check it into git and checkout in Windows. Then I go to the project folder and run grunt, and then it fails with:
Running "mocha:all" (mocha) task
Testing: http://localhost:9000/index.html
Running PhantomJS...ERROR
>> 'c:\Users\Edy' is not recognized as an internal or external command,
0 [ '\'c:\\Users\\Edy\' is not recognized as an internal or external command,\r',
>> 'operable program or batch file.' ]
>> operable program or batch file. 1 [ '\'c:\\Users\\Edy\' is not recognized as an internal or external command,\r',
>> 'operable program or batch file.' ]
Warning: PhantomJS exited unexpectedly with exit code 1. Use --force to continue.
Uninstalling phantomjs and installing it locally doesn't help. Installing globally doesn't help either. So the only way to make it work on Windows seems to be deleting the node_modules dir and reinstalling on Windows, which brings me to the first issues on Linux.
Is there a way to use nodejs stuff in a cross platform environment like mine? I cannot believe I'm the first one with such a setup out there hehe
Any tips or help in this is appreciated. Thanks!
Many dependencies in node.js use native addons. Native addons are compiled for your specific environment when you npm install.
If you're moving between environments, you can npm rebuild to rebuild those binaries for the new environment. Or the more lengthy way, remove the node_modules folder and npm install again.
Fatal error: spawn ENOENT means a process node.js is trying to spawn does not exist. A common case when trying to spawn a binary compiled for another environment, the binary it is expecting does not exist.