I am having trouble running grunt-cli after installing it. I run
npm install -g grunt-cli
then running grunt errors with
node.js:63
throw e;
^
Error: Cannot find module 'findup-sync'
at loadModule (node.js:275:15)
at require (node.js:411:14)
at Object.<anonymous> (/home/tmartin/bin/grunt:9:14)
at Module._compile (node.js:462:23)
at Module._loadScriptSync (node.js:469:10)
at Module.loadSync (node.js:338:12)
at Object.runMain (node.js:522:24)
at Array.<anonymous> (node.js:756:12)
at EventEmitter._tickCallback (node.js:55:22)
at node.js:773:9
This is what I have installed:
tmartin#timcomp:~$ npm list -g
/home/tmartin/lib
└─┬ grunt-cli#0.1.6
├─┬ findup-sync#0.1.2
│ ├─┬ glob#3.1.21
│ │ ├── graceful-fs#1.2.0
│ │ ├── inherits#1.0.0
│ │ └─┬ minimatch#0.2.11
│ │ ├── lru-cache#2.2.2
│ │ └── sigmund#1.0.0
│ └── lodash#1.0.1
└─┬ nopt#1.0.10
└── abbrev#1.0.4
I had to install and link findup-sync and a few other npm packages to get these dependency issues to go away. I though npm was supposed to handle them for us, but installing the dependencies manually made the issues go away.
npm install findup-sync -g
npm link findup-sync
I got mine running again reinstalling grunt-cli globally and in my repo.
npm install -g grunt-cli
cd myrepo
npm install grunt-cli
I think Yosemite installation broke some things in my files ...
This is because npm doesn't set the right permission to sub-directory node_modules in /usr/lib/node_modules/grunt-cli.
In my case, I had:
drwxr-x--- 6 nobody root 4096 16 févr. 17:08 node_modules
When running grunt as non-root user, I had the same error (Cannot find module 'findup-sync') because of a permission denied to read this directory.
The solution is to fix permission with chmod: chmod a+rx node_modules.
But in fact, all directories was involved. The best way was to todo:
find /usr/lib/node_modules/grunt-cli -type d -exec chmod a+rx {} \;
This is maybe a distribution bug (I use Archlinux).
This may seem simple, but if anyone else is unsure if there's a permissions problem, try running sudo grunt then go from there.
I use NVM and was having this problem whenever I changed the active node version.
Following #davidcondrey 's suggestion worked for me. The catch really was to install grunt-cli before grunt. The order made a difference and fixed it.
npm i -g grunt-cli grunt
#inostia 's answer of using sudo to test the permissions was OK, but gave me quite a headache with file permissions, as all the grunt-processed files were inacessible by git later and broke my versioning.
This also may be obvious, but in my case I had set up my npm path off my home directory (on a chromebook) and needed to add .node_modules to my .profile
PATH=~./node_modules:$PATH
Then run:
source ~/.profile
I was able to fix this by reinstalling Grunt using these commands:
sudo npm remove -g grunt-cli
sudo npm install -g grunt-cli
This issue occurs if you change your NodeJS version.
After changing the node version, re installing grunt or npm install will resolve the issue.
Tried all the answers above and I could not get grunt to work without using sudo
Finally came across this Wordpress article and deleted the link to /usr/local/lib/node_modules/grunt/bin/grunt
lrwxrwxrwx 1 root root 35 Apr 19 22:45 /usr/local/bin/grunt -> ../lib/node_modules/grunt/bin/grunt
using sudo rm /usr/local/bin/grunt
Then I linked to the grunt executable in /usr/local/lib/node_modules/grunt-cli/bin
using sudo ln -s /usr/local/lib/node_modules/grunt-cli/bin/grunt /usr/local/bin/grunt
Now, I can run grunt without using sudo
I solved this by running:
npm install -gg grunt-cli --force
Related
I have tried any ways I can but still can't install express successfully.
I used
sudo npm install -g express-generator
sudo npm install -g express
The terminal shows
/usr/bin/express -> /usr/lib/node_modules/express-generator/bin/express
express-generator#4.13.1 /usr/lib/node_modules/express-generator
├── sorted-object#1.0.0
├── commander#2.7.1 (graceful-readlink#1.0.1)
└── mkdirp#0.5.1 (minimist#0.0.8)
But when I input express, it still says "command not find". I also added the path"/usr/lib/node_modules/express-generator/bin" in system path, it still failed.
I stuck this problem for two days, it's quite annoying. Please help me.
Try $ sudo npm cache clean and then install express and express-generator without sudo.
I run the following command in my bash and I get the related results:
merianos#merianos-desktop:~$ sudo npm install -g grunt-cli
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
grunt-cli#0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.7)
└── findup-sync#0.1.3 (lodash#2.4.2, glob#3.2.11)
and
merianos#merianos-desktop:~$ grunt
/usr/bin/env: node: No such file or directory
I also have try to install bower and gulp but again, when I try to execute them, I get a message related to the grunt above.
Can someone please help me ?
Just to know, I just installed Ubuntu 15.04. I don't know if that helps :)
Ubuntu package nodejs provide a binary as a /usr/bin/nodejs, not a /usr/bin/node, so most of cli tools can't find it. To solve the problem you need to make a symlink:
sudo ln -sT /usr/bin/nodejs /usr/bin/node
npm knows that grunt is installed globally, so why isn't it found?
$ npm install -g grunt
... installs ...
$ npm list -g | grep grunt
│ ├─┬ gruntfile-editor#0.2.0
│ ├─┬ gruntfile-editor#0.2.0
├─┬ grunt#0.4.5
│ ├─┬ grunt-legacy-log#0.1.1
│ ├── grunt-legacy-util#0.2.0
$ grunt
-bash: grunt: command not found
I assume because it's put it somewhere that is not on my PATH.
Why doesn't npm just put it somewhere that is on my PATH by default, like /usr/local/bin?
UPDATE: Weirdly, I get the same grunt: command not found error even after I do npm install grunt to run it locally. What am I doing wrong? There is a Gruntfile.js in my repo.
The package "grunt" is the task runner itself whereas the "grunt-cli" package is the command line interface that includes the grunt executable. You can make sure that it is installed to the correct path.
If you do npm install grunt-cli it still would not work because this would be installed to node_modules in the corresponding directory which is most likely not on your path. However, when you use grunt from the globally installed CLI tool it will look for an installation of grunt that is local to that project as well as the Gruntfile.js
what you have to do is
install grunt-cli globally:
$ npm install grunt-cli -g
install grunt local in your dependencies (optionally save the dependency to your package.json):
$ npm install grunt --save
For me there was another thing missing, adding the path to NPM's folder in Window's env variables
Go to System (My computer->Properties)
Advanced System Settings
In Advanced tab, 'Environment Variables'
Under User variables, choose Path, then Edit
Add this alongside the others you have: '%USERPROFILE%\AppData\Roaming\npm'
Hope this helps, g'luck
Edit: Adding ~/npm/bin to path with PATH=$PATH:~/npm/bin helped, thank you Joachim Isaksson
EDIT:
Seems like i cannot install any packages with npm. After sucessfully installing them, i cannot use them with the assigned commands in the package. "No command '' found".
node -v
v0.11.14
npm -v
2.0.0
At ubuntu machine
It seems like i cannot install the resume-cli module, found here with using npm. Even though it installs without errors, it does not understand the basic commands after installing. Could it be a problem with the warning, showed under?
sudo npm install -g resume-cli
i get
npm WARN engine html-to-text#0.0.8: wanted: {"node":"~0.8.0"} (current: {"node":"0.10.32","npm":"1.4.28"})
Then
/home/bjornasm/npm/bin/resume -> /home/bjornasm/npm/lib/node_modules/resume-cli/index.js
resume-cli#0.3.10 /home/bjornasm/npm/lib/node_modules/resume-cli
├── cli-spinner#0.1.5
├── char-spinner#1.0.1
├── commander#2.3.0
├── colors#0.6.2
├── open#0.0.5
├── chalk#0.4.0 (has-color#0.1.7, ansi-styles#1.0.0, strip-ansi#0.1.1)
├── async#0.9.0
├── read#1.0.5 (mute-stream#0.0.4)
├── terminal-menu#0.3.2 (inherits#2.0.1, charm#0.1.2, resumer#0.0.0)
├── superagent#0.18.2 (extend#1.2.1, qs#0.6.6, methods#1.0.1, cookiejar#2.0.1, component-emitter#1.1.2, reduce-component#1.0.1, mime#1.2.11, debug#1.0.4, readable-stream#1.0.27-1, form-data#0.1.3, formidable#1.0.14)
├── resume-to-text#0.0.15 (mustache#0.8.2, html-to-text#0.0.8)
├── resume-to-html#0.0.21 (gravatar#1.0.6, resume-to-markdown#0.0.14, marked#0.3.2, mustache#0.8.2, lodash#2.4.1)
├── jsonlint#1.6.2 (nomnom#1.8.0, JSV#4.0.2)
└── resume-schema#0.0.15 (z-schema#2.4.10)
Then when running the following
resume --help
i get
resume: command not found
Anyone familiar with this?
Below are the steps to install a given release from source
NOTE - this installs nodejs which gives you both node as well as npm, they come together per release.
to start fresh remove prior node.js and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :
export NODE_PARENT=${HOME}/bin_0_10_32
mkdir ${NODE_PARENT}
download source from : http://nodejs.org/download/
cd node-v0.xxxx
./configure --prefix=${NODE_PARENT}/nodejs
make -j8
make install # IMPORTANT this is NOT using sudo
# not wanted since installing into $USER owned $NODE_PARENT
which puts it into dir defined by above --prefix
export PATH=${NODE_PARENT}/nodejs/bin:$PATH
define environment variable NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into current dir :
export NODE_PATH=${NODE_PARENT}/nodejs/lib/node_modules
when you use syntax : npm install -g some_cool_module
the -g for global installs it into dir $NODE_PATH and not your $PWD
nodejs install gives you npm as well :
ls -la ${NODE_PARENT}/nodejs/bin
Subsequent modules you install using global flag -g will automagically put their ~binaries~ into above bin dir ... like browserify
Now put above three export xxx=yyy
commands into your ~/.bashrc or some such so your environment is setup
I tried to install gulp by
npm install -g gulp
The output seems to be something like this. (i have skipped some logs)
npm http 304 https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/lodash._htmlescapes
/usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js
gulp#3.6.2 /usr/lib/node_modules/gulp
├── tildify#0.2.0
├── pretty-hrtime#0.2.1
├── deprecated#0.0.1
├── archy#0.0.2
├── semver#2.2.1
├── chalk#0.4.0 (has-color#0.1.7, ansi-styles#1.0.0, strip-ansi#0.1.1)
├── orchestrator#0.3.3 (sequencify#0.0.7)
├── liftoff#0.9.8 (extend#1.2.1, minimist#0.0.8, resolve#0.6.3, findup-sync#0.1.3)
├── vinyl-fs#0.1.4 (graceful-fs#2.0.3, map-stream#0.1.0, mkdirp#0.3.5, vinyl#0.2.3, glob-stream#3.1.9, glob-watcher#0.0.6)
└── gulp-util#2.2.14 (lodash._reinterpolate#2.4.1, dateformat#1.0.7-1.2.3, minimist#0.0.8, vinyl#0.2.3, multipipe#0.0.2, through2#0.4.1, lodash.template#2.4.1)
In the above script i can see a line
/usr/bin/gulp -> /usr/lib/node_modules/gulp/bin/gulp.js
which i guess is making a simulink in bin folder. So i should be getting gulp globally but i get the this error.
No local gulp install found in /var/www/ksapp
Any idea why i am getting this error.
Thanks
As pointed out in the doc, you should install it globally (you did that) and add it to your project dev deps (locally):
npm install gulp --save-dev
I faced the same issue. Got it resolved by creating a link
npm link gulp
Check /home/username/.npm directory: maybe groups/owner of files is root. Change to username:
chown -R username.username /home/username/.npm
I've recently run into the "Local gulp not found" error message. I was able to work past it by creating a symlink from the global node_modules directory to the local project directory where my gulpfile.js is located.