I have installed node.js. Node seems to be working properly, however, npm is not being found, as you can see below.
C:\Users\jpdrc>node -v
v6.5.0
C:\Users\jpdrc>node hello.js
node is installed!
C:\Users\jpdrc>npm -v
module.js:457
throw err;
^
Error: Cannot find module 'strip-ansi'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\jpdrc\AppData\Roaming\npm\node_modules\npm\node_modules\npmlog\node_modules\gauge\node_modules\string-width\index.js:2:17)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
I have tried multiple solutions as the ones presented:
1- Windows -installed node.js but npm not found
2- Installing Node.js (and npm) on Windows 10
I have no idea what to try next
Thanks for the assistance
Here are my variables under path
As suggested below I have used where npm
C:\Users\jpdrc>where npm
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
Steps for solving the above issue:
Check that you have added the path of node in environment variable "path"
If it is there then check that npm is there in the directory which you have added in the path.
If npm is there in the required folder then go to CMD and then go to directory where npm is installed and try to run the version command again. If still you are getting the same issue then there could be two possibilities:
a. Installation is incorrect, try installing again
b. There could be proxy issue due to which packages are not getting downloaded
There cannot be any other issue.
You should be able to run the npm -v in the git bash terminal window. If you don't even have the git-bash app, then download and install git on your Windows.
Related
I have never used node.js before, and I have been researching the answer to this question, but I have had no luck.
I am trying to allow the user to enter an input number (and honestly have no idea how to do this). Upon some research I tested a very simple input/output code:
var readline = require('readline-sync');
var term1 = readline.question("Please enter your first binary term: ");
console.log("your number : " + term1);
But when I try this I am getting the error:
module.js:550
throw err;
^
Error: Cannot find module 'readline-sync'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/<name>/eclipse-workspace/319/SE319Assignment4/binaryCalc.js:1:78)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
I was wondering if anyone can help me figure out why readline-sync cannot be read, or if there is a better way to write this simple input/output code in general! Thanks
if you don't have the dependency listed in your package.json file, try running this command from your cmd (cd into the directory where binaryCalc.js is located at):
npm install --save readline-sync
if you do have it in there, just try
npm install
Yes you should create a dependency first
So for that just open your folder where your js file is there through terminal. And just follow the following steps.
. npm init
. npm install readline-sync --save
and after this just try to run your code
It will definately not show any error
If you don't have the 'readline-sync' dependency listed in your package.json file, you can try installing it by running the following command from your terminal or command prompt (while in the directory where your project is located):
npm install readline-sync
Or
npm install -D readline-sync #types/readline-sync
Or install it manually
"readline-sync": "^1.4.9"
then run the following command
npm install
I'm receiving this error in javascript console.
I already remove the node_modules and reinstall it and I already run npm rebuild node-sass.
I really don't know what to do anymore.
I'll be very grateful for your help.
app.js:20147 Uncaught Error: Module build failed: ModuleBuildError: Module
build failed: Error: Missing binding /home/vagrant/Quality1/node_modules/node-sass/vendor/linux-x64-57/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 8.x
Found bindings for the following environments:
- Windows 32-bit with Node.js 6.x
- Windows 64-bit with Node.js 6.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass --force` to build the binding for your current environment.
at module.exports (/home/vagrant/Quality1/node_modules/node-sass/lib/binding.js:15:13)
at Object.<anonymous> (/home/vagrant/Quality1/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/vagrant/Quality1/node_modules/sass-loader/index.js:4:12)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
npm rebuild node-sass --force (response)
make: Leaving directory/home/vagrant/Quality1/node_modules/node-sass/build'
gyp info ok
Installed to /home/vagrant/Quality1/node_modules/node-sass/vendor/linux-x64-57/binding.node
node-sass#3.13.1 install /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass
node scripts/install.js
node-sass build Binary found at /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-57/binding.node
node-sass#3.13.1 postinstall /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass
node scripts/build.js
Binary found at /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
node-sass#4.5.3 /home/vagrant/Quality1/node_modules/node-sass
node-sass#3.13.1 /home/vagrant/Quality1/node_modules/gulp-sass/node_modules/node-sass
`
change "gulp-sass": "^2.3.2"
to
"gulp-sass": "3.0.0" in package.json
clear the node_modules folder by removing it and then run
npm install
again and it'll not give the error!
You are using node-sass#3.13.1. There was never support for Node 8 for that version.
You can solve this problem in two ways:
Use node-sass#4.5.3 or higher (currently the latest one is 4.7.2). Sometimes node-sass is the dependency of another package, then try to update this package.
Use Node 6. The easiest way to manage different versions of Node between your projects is to use NVM or NVM Windows. I also suggest you use .nvmrc file, that contains desired Node version. Then you will be able to switch between Node version with simply $ nvm use in a project directory.
So i moved to the directory where the .js file is located and i opend it with node filename.js got nodejs and everything installed on the ubuntu VPS and i get error:
throw err;
^
Error: Cannot find module 'is-property'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/www/bot/node_modules/steamcommunity-mobile-confirmations/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/index.js:1:80)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
what is the problem? or m i trying to run this file completly wrong?
It looks like you need to install a dependency.
Try running the following command in your terminal
npm install is-property --save
If you're trying to run a script with a package.json file, that should define all the dependencies you need. All that's left to do is run npm install in the project directory.
If there's no package.json defining dependencies, you'll need to install each missing dependency. As you've found out, it'll throw a missing module error if they're missing. You might run into this issue multiple times if there are multiple missing modules. To remedy that, either dive into the code, and look for require('package-name') statements that don't reference a local path. (E.g. require('./package') is a local file, whereas require('package') will look for an npm installed module.) Alternatively, you can just keep trying to run it, and install each missing dependency manually until it stops spitting out errors.
I highly recommend creating a package.json if one doesn't exist yet. You can use npm init, and any installed packages should be automatically added to it. Then you can save additional packages to it using npm install package-name --save, or npm install package-name -S. That way, if you use the same code on another machine/in another directory, you don't have to copy over the node_modules folder, as you can specify which packages/versions you want and install them with a single npm install.
Additionally, you may wish to read up on what the package.json file is in relation to node.
NPM Docs on package.json
I am going to use the Ionic framework to work on hybrid app development, so I installed all the necessary dependencies (node.js, cordova, etc.) and followed their Getting started section. Step number 3 simply involves running the following command within the app directory:
> ionic platform add android
However midway during the execution I got the following error:
module.js:341
throw err;
^
Error: Cannot find module 'config-chain'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\james.bonello\AppData\Roaming\npm\node_modules\cordova\node_modules\npm\lib\config\core.js:2:10)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
I ran > npm update first and tried again to see if the update fixes any missing dependencies and such but the problem persisted.
So, as the error clearly states, the module 'config-chain' is missing so I next ran
> npm install config-chain
While that did install the module, the error somehow still persisted (identical to the previous one). I am not sure what to do next and I cannot understand why npm is not recognizing the 'config-chain' module now. Any ideas?
From what I can see, the missing package config-chain is a dependency of the global package cordova.
You should re-install cordova:
npm cache clean
npm uninstall cordova -g
npm install cordova -g
IF the problem persists, you have to manually install the package inside cordova's modules:
C:> cd Users\james.bonello\AppData\Roaming\npm\node_modules\cordova
C:> npm install config-chain
I did npm install and it worked .
I tried to setup ghost after installing node.js but as I run the install for ghost as
npm install --productions
It gives me the following error
> ghost#0.5.10 start /home/kedarkhetia/Downloads/ghost-0.5.10
> node index
module.js:340
throw err;
^
Error: Cannot find module 'streamsearch'
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/kedarkhetia/Downloads/ghost-0.5.10/node_modules/busboy/node_modules/dicer/lib/Dicer.js:5:20)
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)
npm ERR! weird error 8
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! not ok code 0
any help is appreciated.
Try running
npm install streamsearch
Does this work?
This may be related:
Cannot install packages using node package manager in Ubuntu
Make sure you have installed streamsearch.
npm install streamsearch
If it is still not working, check that you have cloned stable for production or not. If you did, re-clone it and do installation steps again. Use sudo for npm/grunt commands (if you are on OSX or Linux) for npm ERR!.
I just looked at the Ghost Docs, and it says to install the dependencies for production you must run npm install --production and not npm install --productions. Once you install streamsearch, it will keep complaining until you have installed all the individual dependencies with npm install --production.
Hope this helps!