Why is this error about Grunt when starting sails - node.js

I am using node 0.12.2 and sails 0.10.5
After doing
sudo npm install
sails fails to lift. I have to
sudo npm install cookie
and then
sudo npm install connect
to make sails lift. Then it shows some error like this:
error: Grunt :: module.js:338
throw err;
^
Error: Cannot find module '/home/ec2-user/someuser/node_modules/sails/node_modules/grunt-cli/bin/grunt'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
and
sudo npm install grunt-cli
does not do anything. nor does installing it globally.
sudo npm -g install grunt-cli
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
/usr/local/lib
└── grunt-cli#0.1.13
[ec2-user#ip-172-*****]$ sails lift
info: Starting app...
error: Grunt :: module.js:338
throw err;
^
Error: Cannot find module '/home/ec2-user/someuser/node_modules/sails/node_modules/grunt-cli/bin/grunt'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Sails still can lift but where does this error come from and how to get rid of it?

The error message pretty describe what's wrong
Error: Cannot find module '/home/ec2-user/someuser/node_modules/sails/node_modules/grunt-cli/bin/grunt'
grunt-cli is missing. You need to install it using (might need sudo)
npm install grunt-cli -g

Edit: Make sure you are running sails lift from your sails project folder. (to me it looks like you are running it from root which is probably the cause of the issue)
Otherwise, I leave my other suggestions here:
Install sails globally: npm -g install sails
Install grunt globally: npm -g install grunt-cli
If the problem still exists after running npm install it is very likely to be related to permission issues. You can fix this permission problems using one of two options:
Change the permission to npm's default directory.
Change npm's default directory to another directory.
I recommend the latter.
Here is an official guide from NPM people on how to do both:
https://docs.npmjs.com/getting-started/fixing-npm-permissions

Related

Error: Cannot find module 'commander'

when I m running sails -v, sails lift or even installing npm I m getting this error Please help -
Error: Cannot find module 'commander'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/sails/bin/_commander.js:6:15)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Most likely commander is missing from package.json. Install it and add it to package.json by doing:
npm install commander --save
Install commander globally.
sudo npm install commander -g
This will install commander module under/usr/lib/node_modules/.
Uninstalling sails and reinstalling with 'sudo' resolved it.
npm uninstall sails -g
sudo npm install sails -g
When i try setup new app with the help of express-generator.
given error:Cannot find module 'commander'
Node version:12.16.1
switch node version :10.16.3
after switch node version is working fine..
In my case it was because of bad version of node. I've tried node 8.15.1 and it works.
On my end, after doing npm install, and attempt to run npm run watch I encountered this same issue of Error: Cannot find module 'commander'.
I did below:
// delete node_modules (can do manually) or command below
// rm -rf node_modules
npm install
And I was able to do npm run watch again.
This maybe because of corrupted packages.

npm cannot find module

I've been all over Google and StackOverflow, viewing the various threads related to similar issues, but so far nothing has worked. My problem is that npm seems to be installing improperly...or something, I honestly have no idea: Node and npm are a dependency I use to support the Sage Wordpress theme buildout I'm working on on a different machine.
So the issue is that after uninstalling Node (to be safe), and reinstalling, Node seems to be working fine. node -v returns v5.1.0. Great. npm should be installed with it, but when I run npm -v I get the following lovely bit of error:
$ npm
module.js:340
throw err;
^
Error: Cannot find module 'readable-stream'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/Daniel/.nvm/versions/node/v5.1.0/lib/node_modules/npm/node_modules/ npmlog/node_modules/are-we-there-yet/index.js:2:14)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
Running any npm command (even just npm) gives me this error, so as suggested in other solutions, I cannot simply run npm install readable-stream. I have also gone through various solutions (removing the node_modules folder, installing via brew, installing via brew without npm, and several others), but none seem to be working.
Any thoughts would be much appreciated.
I was just wrestling with this problem for half an hour (on Mac) after a failed npm update. I'm using Homebrew and I found I had to do the following:
sudo chown -Rv $USER /usr/local/lib/node_modules/ with my username
Then I reinstalled node via Homebrew:
brew uninstall node
brew install node
By this point npm was working again and I went ahead with a successful npm i -g npm
If you're having problems with NPM and you want to reinstall on UNIX I found this to be the easiest solution:
curl -L https://npmjs.org/install.sh | sudo sh
This will reinstall NPM and get it setup to use the latest NPM Version. This will almost always resolve any issues regarding NPM.
When the process is complete you should receive a message saying It worked.
You can run with command line as below:
npm install // you need remove node_modules folder, run npm install

npm install less but can't require via node

mac os x 10.10.5
my node and npm version.
node -v
v4.2.1
npm -v
2.14.7
then refer to official website I install less.
sudo npm install -g less
sudo npm install -g less-plugin-clean-css
and I confirm that successfully installed in node_modules
ls /usr/local/lib/node_modules/
appcelerator generator-webapp ios-sim yo
bower grunt-cli less
cordova gulp less-plugin-clean-css
express ionic npm
but when I use node command line to require less, some error occured..
> var less = require('less')
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at repl:1:12
at REPLServer.defaultEval (repl.js:164:27)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:393:12)
at emitOne (events.js:82:20)
>
I google it but find nothing which could solve it, please some help ..
require doesn't load global modules by default. the modules must be located in the local node_modules folder.
If you really want to use global modules, you can set the NODE_PATH env variable (but this is bad practice in my opinion):
export NODE_PATH=/usr/local/lib/node_modules/
Here is some background information.
i think your less module in not install perfectly,
As you used command sudo npm install -g less It install Less module globally,
Now you redirect your terminal to your project folder and Use the Following Command sudo npm install less ,remember use it without using -g.
For more information you can visit the enter link description here
I'm install it locally, without '-g' flag in working folder and now it works.
You should open issue on their gitbug if you want to install it correctly globally.

Nodejs and npm error. modules missing

module.js:340
throw err;
^
Error: Cannot find module 'vinyl'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/morpheyesh/debugall/web-starter-kit/node_modules/gulp/node_modules/gulp-util/lib/File.js:1:80)
at Module._compile (module.js:456:26)
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 Module.require (module.js:364:17)
I have major issues with node.js. I try to run any nodejs application or gulp, i get this error, I try to install every module , I keep getting the same error and it requires a new module. Is there anyway where I can install all the modules?
Plus, I have install nodejs through npm? how to install system wide? Gulp is been installed system wide(global). What is causing this error?
nodejs -v gives v0.10.30
`npm -v gives 1.4.21
gulp 3.8.7
I am working with the google web starter kit. I installed nodejs using apt-get, then install sass, then installed gulp, then npm. Is there a way where I can remove all these and install all of it system wide?
Try updating your global gulp installation:
sudo npm install --global gulp#latest
It sounds like everything is (was?) FUBAR for a while there. If you have not yet solved these problems, here's what I would recommend.
First, the official (Debian/Ubuntu) packages are a bit behind latest node. I would recommend uninstalling the packages nodejs and nodejs-legacy and following the instructions here to get the latest versions (packaged and published by nodesource): https://github.com/nodesource/distributions#usage-instructions
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
Now you will have a recent node (0.10.35) but an out-of-date npm. Upgrade your npm:
npm install -g npm#latest
Things should now work for you; you should be able to run npm install in your project directory and all dependencies will be installed correctly.
One thing to be wary of is that you should never run npm update or npm update -g. This does not update the current (or all global) packages, as one might think.
Try this for install all plugins required by gulp :
npm install gulp-jshint gulp-sass gulp-concat gulp-uglify gulp-rename --save-dev
Source : http://travismaynard.com/writing/getting-started-with-gulp
For me uninstalling gulp and then reinstalling it worked fine. This is with node v5.0.0
sudo npm uninstall -g gulp
npm install -g gulp

Node.js and Grunt install on Windows

I have Node.js installed and I have ran npm install -g grunt-cli I have cd to the directory of the app I am to work on and followed the instructions here. When I run grunt in my cmd it returns
module.js:340
throw err;
^
Error: Cannot find module '\\Server\username$\Redirected\AppData\npm\AppData\npm\node_modules\grunt-cli'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
I really am not sure why its trying to read from \AppData\npm\AppData\npm\ as I haven't made any changes and I don't know how to change the grunt location
But when I use npm install -g grunt-cli it downloads and installs to the following \\Server\username$\Redirected\AppData\npm\node_modules\grunt-cli
You need to change the global install directory.
Try this ..
In C:\Users{username}\, create .npmrc file with contents:
prefix = "C:\\Users\\{username}\\AppData\\Roaming\\npm"
This is discussed more fully here:
Change default global installation directory for node.js modules in Windows?

Resources