I have downloaded the stylus .zip from Github and have placed it into the same directory as the node executable. After that I run the following code:
install stylus
But I do not get a response. The command prompt reads
...
Has anybody had this problem installing stylus before? I have Windows. Please help me figure out whats wrong.
EDIT:
I have updated my PATH variable as well
It is recommended to install Node.js packages through NPM, like so:
npm install stylus - for local usage (for your project)
or
npm install stylus -g - install it globally, use it everywhere
Related
I am making a change to someone else's repository. When I try to run the code using node app.js it gives me "Module not found". Do I need to do npm install?
When you clone or fork code from git repo you always want to run npm install in the projects root folder.
This will install all necessary dependencies that projects uses
I have a project that I am using yarn for. I've installed all my packages using yarn, I run yarn dev and so on. Now I'm following a tutorial that requires me to use npx to set up a package. - I'm wondering if I can just go ahead with this or if I will end up mixing things up here, as npx, as far as I know, is related to npm ?
Yes. npx will run the executable from your node_modules directory if it is installed there. If it is not, it will install the executable into a different location. It will not interfere with yarn operations.
I have installed few npm packages globally but it does not show any dependencies in any of my package.json files. Which npm command should I use to apply dependencies in all of my package.json files?
Globally installed dependencies won't list in your local package.json file. You should still be able to use them requiring/importing into your project.
if you want to save a dependency in your package.json as well when you install it, us --save flag with npm install command.
for example
npm install --save express
It is not recommended to add a package which is installed globally to locally or vice versa.
When a package is installed globally, it is normally used as a command in the terminal. For example, create-react-app or express-generator. You might install these packages globally to use them as commands in the terminal to build React or Express app (with default scaffold).
When a package is installed locally, it means you want to use it within the application. For example, jsonwebtoken. You should install this package locally so that it can be used within the application and when somebody else clones your project they can install this package as well via npm install command.
So, the suggestion is, install the package globally if you're going to use it as a command, else install the package locally within the application. Don't mix them.
I'm new and I need to use node for off-line use so, I'm trying to understand how the install modules work.
It's the same if I use npm install express or included it in the package.json?
The way a package is installed will be the same whether you manually type npm install express or put it in your package.json and then do npm install. The difference comes when you try to install your Node project elsewhere.
For example, if your code was checked into GitHub and you didn't include a package.json with all of the dependencies listed, then when the project was downloaded you would have to manually re-install all of the dependencies on the command line in order for it to work. But if you had checked in a package.json with the code, then you could run npm install to install all of the dependencies at once, and not have to remember which ones were necessary.
In addition, the package.json allows you to specify an "approximate version" of a dependency to use. This way if a few packages in your project share a dependency and they all specify similar "approximate versions", only one version will be installed and it will be shared between packages. This saves some install time.
Nothing actually. But you don't want to do that again and again. So you might as well put your module dependencies in your package.json
I'm trying to install and use grunt.
I install using npm install grunt -g
it seems to install -
grunt#0.4.3 /Users/me/.node/lib/node_modules/grunt
when I open up a new tab in terminal and run grunt I get
-bash: grunt: command not found
My path looks like this
$ echo $PATH
/Users/me/.rbenv/shims:/Users/me/.rbenv/shims:/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
Any advice? This is killing me.
I've installed grunt-cli too, still not working -
npm install grunt-cli -g
/Users/me/.node/bin/grunt -> /Users/me/.node/lib/node_modules/grunt-cli/bin/grunt
I open a new tab
-bash: grunt: command not found
I installed node using the node installer. I'm on OSX.
I've just added /.node/bin to my path, see below -
echo $PATH
/Users/me/.rbenv/shims:/Users/me/.rbenv/shims:/.node/bin:/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/.node/bin:/opt/X11/bin:/usr/local/git/bin
It's still not working.
Your path don't contain ~/.node/bin where apparently your globally installed npm binaries are kept.
You need to fix that if you expect said binaries to be picked-up.
Either way, this points out that you missed a step in your node / npm installation. How did you installed node exactly?
I don't know what other people do, but I'm using node from homebrew, which should take care of that for you (I assume from the paths you list that you are on OSX).
try to install grunt globally
$ sudo npm install grunt -G
You may have Grunt 0.4.3 installed globally but nothing installed locally.
Run $ grunt --version to find which version you are on. At this point you'll only be knowing that you do have Grunt installed in your system. But to run Grunt at the directory level (also known as "project level") you'll need to be specific - because not every project may require the Grunt version you have installed globally.
Create a package.json file in the directory you mean to have your project on. Let's call it the project's root folder.
{
"name" : "MyProject",
"version" : "0.1.0",
"author" : "My name",
"private" : true,
"devDependencies" : {
"grunt" : "~0.4.2"
}
}
Navigate to the project's root folder and run $ npm install. The specified Grunt version will be installed as a dependency to the project.
Smile, you have Grunt up and running! :)
Sometimes another version or just a wrong path is referenced in the npm config file instead of the installed version.
This may cause node/npm to misplace global modules.
To check and fix:
In cmd line type: npm config list
You should get a list of configuration values, one of them is prefix.
Make sure the path in prefix is the same path (only without node.exe) as the actually installed node.exe path.
(this path is listed further down as node bin location)
If it's not, change it:
Either in the config file (in your user folder, named .npmrc)
Or, via cmd line: npm config set prefix "C:\Program Files\nodejs" (change path if needed)
Reinstall the module/package you tried to install, don't forget -g for global.