npm install vs npm install <library> - javascript

At work we had problem that wasn't displaying icon (from rc-menu lib) for menu block
Each time when we are running
mvn install
we are also running
npm install
inside package json we had this library
"rc-menu":"^5.10.0"
The way to fix it was to run
npm install rc-menu (Inside package.json directory)
My question why this solution works?
For me it is impossible but maybe I'm missing something?

Your version must be a missmatch.
With npm install {package_name} you are installing the latest version. And with npm install you are installing version that satisfies rules of your package.json.
As far as I can see that module doesn't have 5.10.0 version at all...
5.0.14 is the latest of 105 releases
You can try to see the version of that module if you install it with npm install by typing npm list afterwards.

Related

Cannot install Vue Cli on Mac Catalina [duplicate]

While installing the dependencies of vue-cli, vue is not identified. Why?
rm -rf node_modules and npm install again
have a look here
Add sudo before yarn when installing
yarn global remove #vue/cli
sudo yarn global add #vue/cli
vue
I had the same issue for a while.
TL;DR
npm install #vue/cli-service --save-dev
As the documentation specify it is a development dependency https://cli.vuejs.org/guide/#cli-service
The CLI Service (#vue/cli-service) is a development dependency. It's an npm package installed locally into every project created by #vue/cli.
Origin
I had a fresh install of nodejs
And just did
>> sudo npm install -g #vue/cli#latest
>> vue --version
#vue/cli 4.5.8
The issue
The issue presented like this
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
/bin/sh: 1: vue-cli-service: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The fixes:
npm install #vue/cli-service --save-dev
Which led me straight to another error message
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
ERROR Error: Cannot find module 'vue-template-compiler/package.json'
Which I fixed the same way
npm i vue-template-compiler --save-dev
And now it is working fine.
Installing current version without permanently installing vue-cli.
npx #vue/cli create appname
It shows the vue executable is located at /home/alisha/.local/bin. So probably this location is not there in your $PATH.
You should be able to run the vue commands if you provide the full path, like:
~/.local/bin/vue create hello-world
You can also see if that directory is in your PATH by running some command like:
echo $PATH | grep '.local/bin/'
If it's there, you would see it, otherwise you can add it to your path by placing it in your ~/.profile.
Edit ~/.profile and add the following at the bottom of it.
PATH="$HOME/.local/bin:$PATH"
Hope it helps!!
I had the same issue while making a build for production.
You will require vue-cli to be installed. Use below command to install the latest version.
npm install -g #vue/cli#latest
Then
npm install
Might have to do with you having an old version on your computer:
Warning regarding Previous Versions
The package name changed from vue-cli to #vue/cli. If you have the previous vue-cli (1.x or 2.x) package installed globally, you need to uninstall it first with
npm uninstall vue-cli -g or yarn global remove vue-cli.
You can find it here: https://cli.vuejs.org/guide/installation.html
THIS FIXED THE ISSUE FOR ME:
After running
sudo npm install -g #vue/cli
I ran
sudo nano $HOME/.profile
and pasted the following line
export PATH=$PATH:/home/chike/.npm-global/bin
after writing the code, next thing I did was Ctrl + O, ENTER and Ctrl + X then wrote
vue init webpack myapp
When you install vue using cli that time you got the path of vue.Now you can copy the bin folder path.
In my example /home/sublime/.npm-packages/bin
Now you export the path below command
export PATH=$PATH:/home/sublime/.npm-packages/bin
I solved mine by running (add sudo if needed)
npm i -g vue-cli#2.9.6
npm i -g #vue/cli
Got similar issue when deploy vue project in jenkins.
Here is what I did:
Add node's bin/ dir, to jenkins user's .bashrc file.
e.g
# node
NODE_HOME=/home/dev/.nvm/versions/node/default
PATH=$NODE_HOME/bin:$PATH
Tips - about nvm & yarn
When you manage node version via nvm, make sure you already choose the node version in terminal. e.g:
nvm use stable
node -v
If you use nvm, and installed yarn via npm, then better install vue-cli via npm not yarn, otherwise the vue executable is not placed into node's bin/ dir, at least that's the case in my tests, and as a result will cause you fail to find the vue command.
Using Yarn on Ubuntu it is installed to ~/.npm-packages/bin/. You must add this directory to your PATH. For example run the following command, close your terminal and open a new one.
user#machine:~$ echo 'export PATH="$PATH:~/.npm-packages/bin/"' >> ~/.bashrc
Note: if the file ~/.bashrc does not exist then simply create it.
Following worked for me:
First remove all the existing ones:
yarn global remove #vue/cli
yarn global remove #vue/cli-service
sudo yarn global remove #vue/cli
sudo yarn global remove #vue/cli-service
Then add #vue/cli using sudo:
Note: use sudo if required
yarn global add #vue/cli
yarn global add #vue/cli-service
Then, the final thing to do is to RESTART the terminal.
vue --version
#vue/cli 4.5.9
If you already got a project, the only two things you need to do is:
Delete the directory node_modules (it is safe, since it is not under git and will regenerate in the next step)
In the command-line write yarn install (it will install everything you need)
If you start installing vue-cli manually in a existing project, it the package.json and package-lock.json will be updated. If you already did. Do a checkout from git, and follow my steps above
This may be a problem caused by version conflicts. "export PATH=$PATH:" This is really useful in some cases. But if you are also like me, after trying the direct “export path” method in the comment above, restarting the terminal still can not execute the situation, you can try this way.
Uninstall Vue
npm uninstall -g #vue/cli
Check the local-global npm package installation path, vue is installed in this directory, check if it has been removed.
npm root -g
Install vue (you can check with https://cli.vuejs.org/#getting-started to find the latest command)
npm install -g #vue/cli
Create a connection to the /usr/local/bin directory(You need to find the vue.js path after the local installation first, then replace this path with your latest local install path:/Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js)
ln -s /Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js /usr/local/bin/vue
View version number
vue -v
I was getting the same error because Node.js was not installed. My issue got resolved by installing Node.js using the following command:
sudo apt install nodejs-legacy
To see if you already have Node.js and npm installed and check the installed version, run the following commands:
node -v
npm -v
If both are installed then follow the steps here:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
I installed the package using yarn global add #vue/cli on my Ubuntu box and found the binary in /home/vonkad/.yarn/bin.
I had to modify my /home/vonkad/.bashrc and add the directory to the path export PATH=$PATH:/home/vonkad/.yarn/bin.
To fix this situation, I had to add the following line to my .zshrc (maybe in your case is .bashrc)
export PATH="$(yarn global bin):$PATH"
Effectively, the yarn global bin is a folder where vue (vue-cli 3) was placed.
What helped me
mac os catalina with zsh terminal
Uninstalled node and npm using https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
Downloaded node/npm from https://nodejs.org/en/download/current/
sudo npm install -g #vue/cli
vue --version (#vue/cli 4.5.4)
I faced the same issue and now resolved. In my case I installed Node.js and NPM using the default Ubuntu repository by using this command sudo apt-get install nodejs npm
The problems seemed like those 2 packages are not well maintained so it caused some bugs.
So I purge those packages and reinstall it from nodesource which is officially recommended way to install (reference: Installation instruction from nodesource) using these commands.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Then reinstall #vue/cli again
sudo npm install -g #vue/cli
Now these issues have gone. Hope it helps some programmers.
You need to install vue via sudo like explained in the doc:
https://cli.vuejs.org/guide/installation.html
If you have WSL2 running and you use zsh like me, just add
yarn global add #vue/cli
# add this line to ~/.zshrc
export PATH="$HOME/.yarn/bin:$PATH"
$ vue --version
#vue/cli 4.x.xx
You can try the following code install see
npm install --global vue-cli
vue init webpack <YOUR-PROJECT-NAME-HERE>
cd <YOUR-PROJECT-NAME-HERE>
npm install
npm run dev

How can I use the latest react version (react18)?

When using npx create-react-app my-app, I got this error:
You are running create-react-app 4.0.3, which is behind the latest release (5.0.1).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
I used the command npm uninstall and also check out the getting started with react
but that links suggest the same process
of npx create-react-app my-app. I also used this command npm install react react-dom but this
only install a node modules and a package.json. It doesn't create the usual react boilerplate
and all. Anyone have any idea, please help.
Try this solution :
npx create-react-app#latest myApp
You first need to uninstall the glocal app and then clear the cache and then reinstall it.
npm uninstall -g create-react-app
npx clear-npx-cache
After doing this reinstall it by running following command
npx create-react-app my-app
If it still don't work make sure to update your npm and node version.
If you want to update the react and react-dom of the existing app to the latest version you can do it by following running the following code.
npm install --save react#latest
npm install --save react-dom#latest
If you want to download a specific version of react and react-dom then you can run the following code in your terminal.
npm install --save react#<version>
npm install --save react-dom#<version>
You need to replace with your desired version for example
npm install --save react#17

node-sass installation issue

When I try to install node-sass using npm, I get the following error message:
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":"
The command I use is:
npm install node-sass --save-dev-
You can see more details in the screenshot below:
After struggling , finally found exact solution.
In node js software folder, node-sass\4.5.0 folder is still created in npm-cache folder. So I download win32-x64-48_binding.node manually, put it in C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.5.0 folder.
And run npm install command, issue resolved.
I see you are running node version 8.1.4. You can also check it using node --version in the command prompt.
You'll have to use a version >= v4.5.3 instead because lower versions of node-sass are incompatible with node8. This issue has been reported on their GitHub issue page.
You either have to define using v4.5.3 instead or pass the the -g parameter while installing it, which seems to fetch the latest version automagically.
when i used -g it worked properly and got the latest version
Also, as #javiergarval has pointed out, you have a typo. It should have been --save-dev instead of --save-dev-.
My problem is, that I need an older node-sass Binary, which is not available for the new node version I have. But the solution is, at least on Windows, pretty simple. Just install the windows build tools. With that, npm is able to build the binaries out of the source.
Long story short, this solved the problem for me:
npm install --global --production windows-build-tools
Thanks to the answer on this question:
node-sass installation issue on windows 10
Depends on which node version you are using. Node-Sass currently supports only these versions:
Supported Node.js versions 0.10, 0.12, 1, 2, 3, 4, 5, 6 and 7.
If you happen to work on one of those versions, try to specify which version of node-sass you want:
$ npm install --save-dev node-sass#4.5.3
your npm is trying to download node-sass version 3.31.1 which is does not exist on the releases page of https://github.com/sass/node-sass/releases
You have an error on your command:
$ npm install node-sass --save-dev-
^^^
Should be
$ npm install node-sass --save-dev
(without the last - on dev)
Also, it is giving you a WARNING because it wants to be installed globally.
See the official node-sass documentation.
And also, could be interesting for you to know the differences between --save and --save-dev.
version mismatch with node could be the issue. To install the working node-sass version, you can use
npm uninstall node-sass
npm install node-sass#4.14.0
remember to choose your version number based on the following table, and the node version you have, which you can check by the command node --version
You can find full info here
While searching for the solution, have checked the release versions of node-sass and found that "https://github.com/sass/node-sass/releases" the node file it was looking is committed in the latest release and not in the older version. After downloading the required file "win32-x64-64_binding.node" manually from the released version and placing it under C:\Users\Administrator\AppData\Roaming\npm-cache\node-sass\4.7.2 or simply by using npm install node-sass#latest works for me.
None of the above solutions worked for me, this is what I did:
Installed C++ build tools for Visual Studio
Then:
npm uninstall --save-dev gulp-sass
Under the same circumstances I tried to install the node-sass package. I got the error that it required different version. The culprit turned out to be the fact that I was installing not under client folder but in the main one.
After that I installed the appropriate version for Node (for example 12 -> 4.12) based on the answer from Error: Node Sass version 5.0.0 is incompatible with ^4.0.0

Installing Angular-CLI on Windows 10

I had installation issues of angular-cli on Windows 10 system.
The errors were related to Python dependencies and node-gyp. Something as below :
>execSync#1.0.2 install C:\Users\UserName\AppData\Roaming\npm\node_modules\angular-cli\node_modules\execSync
node install.js
[execsync v1.0.2] Attempting to compile native extensions.
{ Error: spawn node-gyp ENOENT
at exports._errnoException (util.js:1007:11)
Update
this seems to be fixed in newer releases and this solution is no longer required.
mukesh51 eventually solved the problem.
the installation seems to work in these steps:
npm install -g node-gyp
npm install -g windows-build-tools
npm install -g #angular/cli
I took these steps from here.
Uninstall
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
Update Global package
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#latest
I too faced the same issue initially when I installed angular directly using bash. The installation was error completely. Then I attempted to install locally in my project (without removing the global one). That appeared to have solved the problem but got an error on creating a new app.
So i uninstalled everything :
npm uninstall -g #angular/cli
and the reinstalled Angular using Windows Power Shell(as Admin)
npm install -g #angular/cli
This solved the entire problem! Hope it helps!
Use windows power shell to install angular-cli. It will run without any issues.
Windows 10 Solution
Look back at the trace of installation steps ... you may see that it found the Angular binary in the following location:
C:\Program Files\Git\usr\local\node_modules\#angular\cli\bin
I added an ENVT variable using this path and ng worked fine after that
I tried using npm install -g #angular/cli
npm downloaded files successfully and copied files to AppData but not able to use ng -v
After that, I tried following:
npm cache clean --force
Removes npm cache forcefully if you get warning using npm cache clean.
Then try
npm install -g #angular/cli#latest
I have successfully installed by trying the above solution in Windows10.
Both the CLI and generated project have dependencies that require Node 8.9 or higher, together with NPM 5.5.1 or higher.
try update node.js and npm
npm uninstall -g #angular/cli
npm install -g #angular/cli
if doesn't work:
Close the terminal, open a new one or use CMD or Git for windows instead.

c9.io - npm installs outdated packages

I have a workspace on c9.io, and I am using node.js. I am trying to update socket.io from 0.9.17 to the latest version. However, whenever I run the command npm update socket.io it installs the same version. How can I fix this?
To install the latest available package:
npm install <package>
To install a version directly (no need to uninstall first):
npm install <package>#<version>
If you're not sure what versions of a package are available, you can use:
npm view <package> versions
Don't forget the --save flag to add dependencies to your package.json file.
Source: How do I install a previous version of an npm package?
About npm update
However, if app's package.json contains:
"dependencies": {
"dep1": "~1.1.1"
}
In this case, running npm update will install dep1#1.1.2. Even though the latest tag points to 1.2.2, this version does not satisfy ~1.1.1, which is equivalent to >=1.1.1 <1.2.0. So the highest-sorting version that satisfies ~1.1.1 is used, which is 1.1.2.
Source: npm update - Tilde Dependencies

Categories

Resources