npm start and install are not working - javascript

I tried to run npm install and npm start but both does not work. I reinstalled the nodejs but still the same. How to resolve it?

If you're trying to install the dependencies of an existing project (which the context implies), you need to run the command npm install in the directory where the package.json file of the project is.
If you've created a new and empty project folder, you need to first run npm init to create a package.json file which is used to manage the dependencies of your project.

Are you sure you're in the head directory? For example, if your project is in:
$ Documents/Projects/JS-Projects/Work/Client-Management-App/
Then that's the folder you need to be in: the Client-Management-App/ directory, because that's where the package.json file and the /node_modules/ folder will be created.
Also, have you run npm init? That might be another reason why.

Related

installed local npm package is not symlinked

I have installed a local npm package via:
npm i ./my_modules/mypackage
It shows up in my dependencies as:
"dependencies": {
"mypackage": "file:my_modules/mypackage"
}
when I look at the node_modules folder, it shows up in there as well, but it is not symlinked
there is no arrow icon in the explorer indicating it is symlinked
which means I have to rebuild every single time I want to see changes inside the local package
this only just started happening today, I'm not sure why it's not symlinking all of the sudden
how do I resolve this issue so that it symlinks properly? it used to do this automatically and now it isn't. I've even tried re-installing everything on my dev machine and it is still doing this behaviour.
normally when I install a local npm package it will symlink it properly, automatically
now, for whatever reason, it is not symlinking
EDIT
I've even tried using npm link
cd my_modules/mypackage
npm link
cd ../../
npm link mypackage
npm I ./my_modules/mypackage
still doesn't symlink.
Some conflicts could happen. To resolve that go to the root of your npm package folder and call npm unlink<package_name> then in your test folder remove node_modules and even you can delete your package.json. After you reset that you can again go to the root of your npm package and call the npm link then install your local npm package in the test folder and test it out.

module npm file doesn't appear to me

I am trying to follow with pluralsight tutorial and he wrote npm install on the terminal, then a file called npm module is installed on the folder he specified. when I try to install npm this appears to me in the terminal, and the directory which Im trying to install npm on it contains only one document called package-lock.json enter image description here
npm install uses the package.json to install the necessary packages
I can see when you ls, there's no package.json in the directory, just the package-lock which is created where ever you run npm install
Make sure you run the npm install from the same directory the package.json in contained in
the problem is solved, I think that I download the web-dev-starter folder twice by mistake.

How to install npm dependencies inside a sub directory?

I have a package.json in the root: "install": "cd packages/my-package && yarn".
When I run yarn run install all I'm asking is that it goes into this package, installs the node_modules and dependencies and that's it. For some reason no matter what I try (yarn workspaces/lerna/manually etc.) it is installing node_modules in all packages, including the root.
WHY?! Just let me install them separately :(
Anyone knows how to easily fix this?
To move the basefolder of node_modules, you will have to create a .yarnrc file in the same directory as your package.json file. Your .yarnrc file should look like
--modules-folder packages/my-packages
The resulting output will put all of your packages after my-packages
/packages/my-packages/WHERE_YOUR_PACKAGES_GO

What the difference between install a module with npm node console or in package.json

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

unable to run grunt after installing using npm

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.

Categories

Resources