npm doesn't work with node v0.4.12 mac - macos

I don't know if I had npm and node installed on my mac before running the executable from the nodejs.org website, but at this time I am getting this error Error: npm doesn't work with node v0.4.12 after running the install package.
I can't uninstall npm, the npm command is completely useless.
Please assist if you have insight

I would say the safest thing is to manage Node & NPM versions with NVM (Node Version Manager). It installs (compiles) both Node & NPM for you, for each version you choose.

What's happening is that you have the new version of npm installed(v1.x.x) and an old version of node, e.g. v0.4.12, which are incompatible.
The best thing to do is update node, otherwise you could download the old npm install bash script from http://npmjs.org/install.sh and execute it (you might need to do it as sudo) The script will clean up all other versions of npm and install a version compatible with your node v0.4.12

Related

How to install all the dependency package in yarn?

First, I'm new to React. I'm trying to use Google's Material-UI for my React project. In this tutorial, it says run npm install, but I heard using yarn and npm together in the same project because it might bring about some confusion between those two later. So, I'm trying to stick to yarn only.
npm install seems to install all the dependency package for the thing that I wanna use, but how can I do that in yarn? I tried yarn add, but it didn't work. How can I do that?
EDIT
Just found that it has only package.json, which means I can only use npm install to install dependencies. Would there be no problem when I use yarn later?
You should just be able to run yarn ("Running yarn with no command will run yarn install, passing through any provided flags." So just a simple yarn is what you'd want now, this answer previously suggested yarn install)
Here is a comparison table of most/all the commands you'd likely encounter
Edit Sept 2020: The newer versions of npm have greatly improved and caught up to yarn, so I currently have no clue what possible benefits yarn offers anymore, I'm 100% npm for the last year or so
The equivalent of $ npm install is just $ yarn (without arguments) to install all dependencies from package.json.
Also, just to clarify your query -
Just found that it has only package.json, which means I can only use npm install to install dependencies. Would there be no problem when I use yarn later?
Doesn't matter whether you use yarn or npm, there will always be a package.json.
And no, there won't be a problem when using yarn later.
You get package-lock.json when using npm, and yarn.lock file when using yarn.
It's not recommended to use both yarn and npm for the same project, so you should remove either of package-lock.json and yarn.lock.
In my case it worked as - yarn global add #angular/cli (similarly any dependency)
then added path "C:\Users\USER_NAME\AppData\Local\Yarn\Data\global\node_modules.bin" in "Edit the system environment variables" -> Environment Variables -> Under System Variables select PATH-> click New -> Add the above path then save-> Open new command prompt -> run the dependency command.
yarn install --force
From Yarn's help text on the install command:
--force   install and build packages even if they were built before, overwrite lockfile
I had a situation where nom install would install everything and yarn install wouldn't. So maybe try the other package manager?

I Installed npm But Cannot Install DocPad

Obviously I need to download DocPad (file(s)) before I can do an npm install, but it simply isn't clear to me what to download, etc. I know the file(s) I need are on GitHub, but I don't have the background to understand what I'm looking at. Can you give me, or point me to, a "Download DocPad for Dummies" instructions? Thank you.
To extend on #sindis's comment
When you install Node, you will also install npm, which serves as the node package manager.
npm allows you to install packages globally using the -g flag, which installs a package that has been published to npm (such as DocPad) to wherever the npm global installation directory is, and make DocPad's command line tools available to you.
So by installing DocPad with npm install -g docpad#6.78 (6.78 is the version of DocPad that the command above wishes to install) we will install DocPad to the global npm installation directory, which makes the command line tool docpad available for your use.
I've updated the DocPad installation guide to be a bit clearer about this, suggestions welcome.
The installation of DocPad is all controlled by NPM. So once that is installed, all you should need to do to install DocPad is run the npm command, as others have said, npm install docpad -g.
Now, the gotcha in windows is that you might need to execute this command with elevated rights - ie Administrator. Windows doesn't like you installing programs in its root program directory.

Chocolatey, npm and grunt-cli installation problems

I am having an issue with the path that my node packages are installing on Windows 8.1. Having installed node using Chocolatey I done the following steps:
Install Chocolatey
choco install npm
npm install -g grunt-cli
So having done the above I open a cmd prompt in admin mode and type 'npm', it works fine from any directory an gives me the usual npm usage stuff. Next I type 'grunt' and I get ''grunt' is not recognized as an internal or external command...'.
So straight away I think this is a PATH problem which it most likely is.
My PATH had nothing to do with npm on it, so I added 'C:\Users\MYNAME\AppData\Roaming\npm' to it, tried 'grunt' again with no luck. I looked inside 'C:\Users\MYNAME\AppData\Roaming\npm\node_modules' and nothing is installed so I ran 'npm install -g grunt-cli' again and noticed
C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.33\tools\grunt -> C:\ProgramData\chocolatey\lib\nodejs.commandline
.0.10.33\tools\node_modules\grunt-cli\bin\grunt
grunt-cli#0.1.13 C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.33\tools\node_modules\grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.5)
└── findup-sync#0.1.3 (lodash#2.4.1, glob#3.2.11)
So from looking at this npm is installing everything in 'C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.33\tools\node_modules' my question is should I just add this to my path and work ahead or is there something I can do to get npm to use the default install location in 'C:\Users\MYNAME\AppData\Roaming\npm' as the npm-cache in 'C:\Users\MYNAME\AppData\Roaming\npm-cache' seems to filling up as expected?
Thanks
NPM might be tool old from that package. It's my understanding they are no longer offering a separate NPM away from NodeJS (I could be incorrect here, I'd love to be wrong).
I'd prefer using the nodejs.install package (which comes with npm).
To answer your question: the location with a package version is not optimal, but I'm not sure that NPM knows a better location as of the version that is out. I don't have a good answer for you on getting NPM to look at the correct install location based on using the NPM package (which is 1.4.9). https://en.wikipedia.org/wiki/Npm_(software)
Thanks for the reply, your exactly right from my understanding. It's a problem with installing npm via chocolatey which is what I was thinking also but you clarified it.
The fix was to delete the chocolatey node_modules folders and npm from chocolatey, tidy up my PATH and then install node.js from the node.js website and npm comes packaged with that, it updated my PATH and everything now works as expected.
Thanks again!

Phonegap installation error (npm)

I have been searching for a solution for two days now to setup Phonegap on my Windows 8.1
system without any success.
Whenever I try to install Phonegap through npm I get an error that I think has to do
with Cordova(-lib).
To install Phonegap I had to install Node.js (v0.10.28) on my system. After this I opened up Windows Powershell and issued the following command like instructed on the Phonegap website:
npm install -g phonegap
Output: (This is the only part of the error)
error notarget No compatible version found: cordova-lib#'lorinbeer/cordova-lib.git#configparser_module'
error notarget Valid install targets:
error notarget ["0.21.2","0.21.3"]
error notarget
error notarget This is most likely not a problem with npm itself.
error notarget In most cases you or one of your dependencies are requesting
error notarget a package version that doesn't exist.
I also tried installing just Cordova through the npm and then install Phonegap, but that
didn't solve anything either.
Running the Powershell with administrator rights also didn't help and tried solutions of other people who also had problems setting up Phonegap, but nothing works.
I really hope that someone could help me out here.
Thanks in advance.
Download the older version. I think there was a problem in the new one
npm install -g phonegap#3.4
I tried this and worked for me.
I had the same issue yesterday. If you check npm-debug.log, you'll notice that there is a permission issue ("Permission denied") when npm tries to access the cordova-lib git repository url. Actually, cordova-lib is a dependency for phonegap. So, it can't install it and I think that's why you get that error.
So, I tried this: install cordova-lib first then Phonegap. Yet, it still won't work; npm does not seem to check if cordova-lib is installed before trying to do it.
At this point, what I could do is to change the repository from which it retrieves cordova-lib. Here is the NPM install syntax:
npm install <tarball file>
npm install <tarball url>
npm install <folder>
npm install <pkg>
npm install <pkg>#<tag>
npm install <pkg>#<version>
npm install <pkg>#<version range>
This means I can install from a tar.gz file. Great! So, I just went to this page https://www.npmjs.org/package/phonegap to check the phonegap repository and performed these steps:
Download the zip of phonegap-cli repo (https://github.com/phonegap/phonegap-cli/archive/master.zip)
Unzip it
Open the package.json file and find the cordova-lib entry in dependencies (line 32)
Change the value to 0.21.3 which is the last version.
Recreate an archive of the folder to the tar.gz format
Open your CLI and run this command:
npm install -g path/to/archive/phonegap-cli-master.tar.gz
It should work now.
Hope that help!
I had a similar problem today too on Mac, even after Lorenzo said it should be all fine. Just running this:
sudo npm install -g phonegap
... produced loads of errors like this:
error: file ./objects/pack/pack-48c0ff4147fb7e8922546c4a857b98a1cb48e01f.pack is far too short to be a packfile
I combined Lorenzo and arpan shah's solutions:
sudo npm install -g phonegap#3.4
sudo npm cache clean
sudo npm update -g phone gap
... and it seemed to magically work.
Problem
We published with a dependency on a branch of cordova-lib. This fork appears unavailable when lots of requests are coming through (I think). One way or another, it's unreliable.
Changing the dependency to 0.21.3 will cause commands to fail, but will allow the install.
Solutions
update the 'cordova-lib' dependency to the npm published version '0.21.3'
**note, this will allow the install, but other phonegap commands will fail
wait for about 20 minutes, then npm update -g phonegap
testing an update to resolve this issue
further updates momentarily
update
We've pushed version 3.5.0-0.20.3 which should resolve this issue
$ npm update -g phonegap
if that doesn't work, try
$ npm cache clean
and reinstall phonegap
I tryed above comamnds npm cache clear and reinstall phoegap. It downloaded all libs but not command line scripts (phonegap command had still 3.4 as version). I found that better was to give command: npm install -g cordova (v 3.5)!

Grunt installed but not working - "Command not found" on Mavericks

I'm trying to use grunt with sass and have been following these guides:
http://gruntjs.com/getting-started
http://benfrain.com/lightning-fast-sass-compiling-with-libsass-node-sass-and-grunt-sass/
http://www.hongkiat.com/blog/grunt-command-not-found/
I've:
Intsalled node.js
Installed the command-line version of grunt: sudo npm install -g grunt -cli
Added the path from the grunt installer to my bash profile: export PATH=/usr/local/lib/node_modules/grunt/bin:$PATH
Made the profile an executable: source ~/.bash_profile
Setup package.json and Gruntfile.js files in my project root
Installed grunt into the project: cd /path/to/project/root/ and sudo npm install
But when I try to run grunt I see: command not found
It's the same if I run: grunt --version
I wasn't sure if the bash path needs /bin on the end as per the blog posted above but have tried it both ways:
/usr/local/lib/node_modules/grunt/ and /usr/local/lib/node_modules/grunt/bin/
I've also run the grunt installer several times but didn't see any errors so am positive it's installed - can anyone see what I'm doing wrong? I'm running OSX mavericks incase this is the issue.
Any pointers in the right direction would be much appreciated.
Cheers
You have a typo in your command. The package is named grunt-cli without the space.
Update the command to:
sudo npm install -g grunt-cli
And all should work as expected.
Hope this solution also might be helpful to someone. In my case it was a bit trickier.
In command line type the following command
npm install grunt-cli -g
This will show you the location where the grun client is installed:
Copy this location and paste it into a file browser. Was this in my case.
C:\Users\zkhaymed\AppData\Roaming\npm\node_modules\grunt-cli\bin
This will open you the location of a grunt file.
Click on the address line of the location and copy it as a text clicking on the right mouse button.
Now go to the Advanced properties of the system at control panel, and paste this address into a System variables and user variables without deleting the other variables.
I was having a very similar issue, hopefully this helps.
1) You want to check where node and npm are actually installed. If you used a package manager, such as Homebrew or MacPorts, there may be an issue with the location. Just use the downloadable installer from node.js website. Make sure to use the current version, not the long term support (LTS). The installer will install node and npm in /usr/local/bin, which should already be in your PATH. If you already have node/npm installed you can use which node and which npm to see where they are currently located. You should see /usr/local/bin/node and /usr/local/bin/npm, respectively. You will need to update npm after installing with npm update -g npm. This may require sudo.
2) Once node and npm are correctly installed/updated go to the project's root directory (where you have the Gruntfile.js and package.json) and install Grunt using npm install grunt --save-dev. Remember that Grunt After doing so you should see a new folder called node_modules.
3) Make sure to do the previous step before installing the CLI. You can use Grunt's getting started documentation to help guide you the rest of the way. Just be aware that the instructions for installing Grunt are further down the page than installing the CLI, which makes it somewhat confusing. When Grunt and Grunt-CLI are installed run npm install and run grunt in the command line to execute your Gruntfile.js.
You should now be able to see the versions installed. Note that if you are outside of a project's root directory you will not see a version of Grunt but you will see the Grunt-CLI version. This is because the CLI was installed globally (used from any directory/subdirectory) but Grunt is installed on a per-project basis.
Hopefully this helps!
I just ran into this scenario as well. The following worked for me:
Try deleting C:/Users/{username}/AppData/Roaming/npm and C:/Users/{username}/AppData/Roaming/npm-cache (if it exists) and reinstalling global npm modules.
Source: https://github.com/nodejs/node/issues/29287
I had to add this to the PATH (on a Mac after brew install node ):
export NPM_HOME=/usr/local/Cellar/node/6.3.1/libexec/npm
The npm install was not effective, no matter what args I passed to it.

Resources