Yo not working on Windows machine. - node.js

I am working on a windows machine.
Here are my node / npm versions
C:\dev\my-yo-project>node --version
v4.1.1
C:\dev\my-yo-project>npm --version
3.5.2
I am trying to install yeoman. Everything goes fine, but the yeoman doctor complains.
Yeoman Doctor
Running sanity checks on your system
√ Global configuration file is valid
√ NODE_PATH matches the npm root
× Node.js version
Your Node.js version is outdated.
And when I try to run any yo command it looks at some odd place and complains that it could not find the required js.
C:\dev\my-yo-project>yo webapp
module.js:338
throw err;
^
Error: Cannot find module 'C:\Users\MYUSERNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
It should not look at the place it is looking at. It should look at
C:\nodejs\4.1.1\node_modules\npm
which is set in the PATH variable.
Any help please.

Try this:
$ npm cache clean -f
$ npm install -g npm
$ npm install -g yo

Related

create-react-app returns an Error: Cannot find module 'react-scripts/scripts/init.js' when executed

when I try to create a react project with both npm and yarn, it shows me the following error:
I tried to reinstall node and make sure it was up to date, as well as create-react-app by running npm install -g create-react-app#latest. I also removed the npm and npm-cache folders and the environment variable, but nothing works for me and I keep getting the same error.
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'react-scripts/scripts/init.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at [eval]:2:20
at Script.runInThisContext (vm.js:122:20)
at Object.runInThisContext (vm.js:329:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at evalScript (internal/bootstrap/node.js:589:27)
Aborting installation.
node has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting test/ from C:\Users\Esper\projects
Done.
I think the problem arose from restoring my windows 10 to a previous state due to operating system problems, because before restoring it, when I run create-react-app it worked correctly.
create-react-app --version
3.1.1
node -v
v10.16.3
npm -v
6.9.0
SO
Windows 10 Education
Install a package.json with npm init (press enter till is installed)
After that install react-scripts with npm i react-scripts,
Then you can install react with npx create-react-app your-app.
Change the directory to "your-app"
Run again npm i react-scripts and it should work.
Hope I did not missed a step, let me know if works :)
Just run this code on git bash:
npm install
npm install react-scripts
npx create-react-app your-app-name
Maybe it will help somebody else.
This error can happen after you use create-react-app in case you have some invalid character in your path.
Remove charecteres like & from your path.
For example, change from this:
C:\Users\...\Documents\Section 3 Components & Start\my-app
To this:
C:\Users\...\Documents\Section 3 Components Start\my-app

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.

Why is this error about Grunt when starting sails

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

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

Resources