NPM fails to install types - node.js

I have a problem with npm install, in that it won't install #types.
This works fine
npm install --save lodash
However asking for types does not
npm install --save #types/lodash
PS C:\Development\Temp> npm install --save #types/lodash
npm WARN `git config --get remote.origin.url` returned wrong result (git://github.com/types/lodash)
npm WARN `git config --get remote.origin.url` returned wrong result (git#github.com:types/lodash)
npm ERR! git clone git#github.com:types/lodash Cloning into bare repository 'C:\Users\myuser\AppData\Roaming\npm-cache\_git-remotes\git-github-com-types-lodash-9eb5372a'...
npm ERR! git clone git#github.com:types/lodash Host key verification failed.
npm ERR! git clone git#github.com:types/lodash fatal: Could not read from remote repository.
npm ERR! git clone git#github.com:types/lodash
npm ERR! git clone git#github.com:types/lodash Please make sure you have the correct access rights
npm ERR! git clone git#github.com:types/lodash and the repository exists.
npm ERR! addLocal Could not install types/lodash
npm ERR! Error: ENOENT: no such file or directory, stat 'C:\Development\Temp\types\lodash'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Windows_NT 10.0.15063
npm ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\ProgramData\\chocolatey\\lib\\npm\\tools\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "#types/lodash"
npm ERR! cwd C:\Development\Temp
npm ERR! node -v v8.6.0
npm ERR! npm -v 1.4.9
npm ERR! path C:\Development\Temp\types\lodash
npm ERR! syscall stat
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Development\Temp\npm-debug.log
npm ERR! not ok code 0
PS C:\Development\Temp>
This has got me scratching my head. I've updated Chocolatey, NodeJS, NPM to make sure their own the latest versions. Tried the commands on empty folders or an existing TypeScript project - thinking it might be getting confused being ran within a Git repository (error: remote.origin.url). Looking at the GitHub URL it makes no sense git://github.com/types/lodash
I took these examples from MSDN Blog - The Future of Declaration Files
Update: I've uninstalled Node.js and tried reinstalling v6.11.3 LTS or v8.6.0. However the #types command still fails.
Update 2: I've realised Chocolately was masking the npm version. I removed the Chocolately folder, and upgraded npm as per #Louis answer.

Upgrade your npm version to version 4 or 5. I'm mentioning 4 because I ran into problems with 5, and using 4 is still viable. I don't know of any good reason to run an older version.
You are using npm version 1.4.9, as shown in this line of the log:
npm ERR! npm -v 1.4.9
The problem is that npm versions prior to version 2 do not support scoped packages. Packages that begin with an # are scoped packages, so #types/lodash is a scoped package. You need npm version 2 or greater to install it. If you were to use the latest npm in the 1.x series (1.4.29), you'd get a better error message:
npm ERR! Error: This version of npm doesn't support scoped packages (caused by reference to #types/lodash). Update to npm#2+.
Version 1.4.9 did not even know that scoped packages were a thing, so it cannot give a nice error message. It looks like it took the # symbol as signifying that the package name is an address and filled in the missing information with Github as the default host.
The upgrade command I typically use to upgrade npm is:
npm install -g npm
You can specify a specific version by replacing the npm argument with one that gives specific version number. npm#4, for instance, would install the latest npm in the 4.x series. If you don't specify a version number, you get the latest released version.

Related

Issue when I try to execute npm install

when I run the command npm install, it displays this error:
[log#server:www]$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined#undefined
npm ERR! Found: vue#2.6.14
npm ERR! node_modules/vue
npm ERR! dev vue#"^2.5.17" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue#"^3.0.0" from vee-validate#4.4.4
npm ERR! node_modules/vee-validate
npm ERR! vee-validate#"^4.2.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-06-09T01_39_40_386Z-debug.log
I wonder, how can I fix it? What does it mean?
Thanks
It looks like you're trying to install vee-validate version 4.0 in a Vue 2.x application. You can see the compatible version in the vee-validate repo.
How to fix:
Option 1:
Install an older version of Vee-validate (v2 or v3).
First, you'll need to uninstall the version you currently have installed (I'm assuming you installed vee-validate#next since that's the doc recommendation)
npm uninstall vee-validate#next
You can then find the list of versions available with
npm info vee-validate versions
Finally, install an older version with
npm install vee-validate#3.4.9
Replace the 3.4.9 with whatever version you would like to install - as of the time of writing, 3.4.9 is the latest stable tag
Option 2:
Upgrade from Vue 2 to Vue 3 following the upgrade guide.
Note that this is still a work in progress and may have some stability issues and depending on the state of the project I would consider using the above option for the time being.
Step:-1 Make sure node.js is installed on your system. You can check with the command npm --version or node --version
Step:-2 Clear npm cache. run this command npm cache clear -f
Step:-3 Then try to run npm install

After Upgrading my npm from version 6 to version 7 (node version was 10) I cant install dependencies for some projects

I had node version 10 installed in my system, after upgrading my npm from version 6 to version 7 I couldn't install the dependencies, and I'm getting error so I had to downgrade my node to 6,
(both npm ci and npm i was failing)
And the project I was testing is this:
https://github.com/Giveth/feathers-giveth
the errors were something like this:
npm ERR! code 128
npm ERR! git dep preparation failed
npm ERR! command /Users/username/.nvm/versions/node/v10.23.0/bin/node /Users/username/.nvm/versions/node/v10.23.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/username/.npm/_cacache --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code 128
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command git clone --mirror -q ssh://git#github.com/gulpjs/gulp.git /Users/renjer/.npm/_cacache/_cacache/tmp/git-clone-dfb83c15/.git
npm ERR! npm ERR! fatal: destination path '/Users/username/.npm/_cacache/_cacache/tmp/git-clone-dfb83c15/.git' already exists and is not an empty directory.
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR! /Users/username/.npm/_cacache/_logs/2021-02-18T16_18_35_855Z-debug.log
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/username/.npm/_logs/2021-02-18T16_20_15_536Z-debug.log
This problem usually happen because if you only upgrade the node version of the system, there are some packages and dependencies that are installed according to that version.
This is a manual process, but you have to install the package according that version.
For example (package.json):
In your node 6 version you have some package:
"xyz":^1.2.3
that package was installed and its dependencies to work with node 6
delete manually that package from your package.json and install it manually like
npm install xyz
Then is possible that you notice an upgrade to the version, something like:
"xyz":^4.5.6
Do that for everyone of your packages and probably your problem disappears. That's the way that I have used to solve that problem.
You can also upgrade all the packages to its lasts version but ... if you have many packages and someone is not working you are not going to know which one is failing, and you are going to check it individually.
Maybe (at the moment of writing this answer) if you are using Node 10, the latest package's version is not going to work either because that version could be fixed to work with Node 16 (the LTS (Long term support) version at the moment of writing this answer).
If you haven't done that yet, I suggest to continually upgrade your system to the some LTS version that isn't deprecated.

Unable to upgrade - slimerjs missing...?

I'm running on OSX (El Capitan) with node v5.0.0 and npm v3.3.9. if I attempt an upgrade:
npm upgrade
I get the error below:
npm WARN deprecated lodash#0.9.2: lodash#<2.0.0 is no longer
maintained. Upgrade to lodash#^3.0.0
npm ERR! Darwin 15.2.0
npm ERR! argv "/usr/local/Cellar/node/5.0.0/bin/node" "/usr/local/bin/npm"
"upgrade"
npm ERR! node v5.0.0
npm ERR! npm v3.3.9
npm ERR! code EREADFILE
npm ERR! Error extracting /Users/ekkis/.npm/slimerjs/0.9.5/package.tgz
archive: ENOENT: no such file or directory, open
'/Users/ekkis/.npm/slimerjs/0.9.5/package.tgz'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! [https://github.com/npm/npm/issues]
npm ERR! Please include the following file with any support request:
npm ERR! /Users/ekkis/Downloads/client-side-testing-0.1/npm-debug.log
I've tried uninstalling this slimerjs (whatever that is) both locally and globally but it still fails. if I look in the given directory there is indeed no 0.9.5 installed but I do find a 0.9.6
so what requires it and why isn't it satisfied with the later version? and most importantly, how do I fix it?
someone suggested 3.3.9 was rather behind the times. upgrading (now v.3.5.2) seemed to solve the problem:
sudo npm install -g npm
The problem is known in the NPM project here - https://github.com/npm/npm/issues/10057. There's an issue with npm#3.x when installing packages having "latest" set to a pre release version.
My fix was to downgrade npm to 2.14.10 - the latest stable in the 2.x series since there was no fix yet posted.
sudo npm install -g npm#2.14.10
for timebeing, Install specific version of slimmerjs eg. npm install slimerjs#0.9.5
https://github.com/graingert/slimerjs/issues/34

Travis - Control Which Node Version is used for NPM Installs

I am attempting to install an npm package (markdown-pdf) as part of my Travis-CI build which I believe is not compatible with old versions of Node. On my local machine, I am running Node version 0.10.36, and it works here, so I added what I believe to be the accepted way of defining a specific version to the top of my .travis.yml file (although I'm not clear on that either). The MCVE version of the full file is below.
language: node_js
node_js:
- "0.10"
install:
- sudo apt-get install npm
- npm config set registry http://registry.npmjs.org/
- sudo npm install -g markdown-pdf
script:
- echo "stuff was installed."
At the top of the build log, I see the following, which seems to indicate that my change worked:
$ nvm install 0.10
######################################################################## 100.0%
Now using node v0.10.40
$ node --version
v0.10.40
$ npm --version
1.4.28
$ nvm --version
0.23.3
However, further down the log, when travis attempts to execute sudo npm install -g markdown-pdf, the log reports the following. Notice that it suggests that the package might not be compatible with the version of Node that is installed, and it claims that I'm using Node v0.6.12.
$ sudo npm install -g markdown-pdf
npm http GET http://registry.npmjs.org/markdown-pdf
npm http 200 http://registry.npmjs.org/markdown-pdf
npm ERR! Error: No compatible version found: markdown-pdf
npm ERR! No valid targets found.
npm ERR! Perhaps not compatible with your version of node?
npm ERR! at installTargetsError (/usr/share/npm/lib/cache.js:488:10)
npm ERR! at next_ (/usr/share/npm/lib/cache.js:438:17)
npm ERR! at next (/usr/share/npm/lib/cache.js:415:44)
npm ERR! at /usr/share/npm/lib/cache.js:408:5
npm ERR! at saved (/usr/share/npm/lib/utils/npm-registry-client/get.js:147:7)
npm ERR! at Object.oncomplete (/usr/lib/nodejs/graceful-fs.js:230:7)
npm ERR! You may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR! reportbug --attach /home/travis/build/ahemmeter/ahemmeter.github.io/npm-debug.log npm
npm ERR!
npm ERR! System Linux 2.6.32-042stab108.3
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "markdown-pdf"
npm ERR! cwd /home/travis/build/ahemmeter/ahemmeter.github.io
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message No compatible version found: markdown-pdf
npm ERR! message No valid targets found.
npm ERR! message Perhaps not compatible with your version of node?
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/travis/build/ahemmeter/ahemmeter.github.io/npm-debug.log
npm not ok
I think I've provided enough information, but you can also look at the public build logs for the project and the github repository it's building.
Have I made a mistake in declaring which version of Node to use? Do I need to (or should I) do something similar for npm, nvm, and markdown-pdf? How can I force npm-install to use the newer version of Node rather than the old one?
Note that I set the repository to download over HTTP instead of HTTPS. When I did that, the error message changed from "failed to fetch from registry: markdown-pdf" to "No compatible version found: markdown-pdf", which seemed like a step in the right direction, so I kept it; however, I mention it here in case there is a possibility that it causes a conflict.
In order to specify dependencies when using node.js, travis seems to expect a package.json file. You can also use this to specify which version of the node package you want to download.
.travis.yml
language: node_js
node_js:
- "0.10"
script:
- echo "stuff was installed."
package.json
{
"name" : "ahemmeter.github.io",
"version" : "0.0.0",
"dependencies" : {
"markdown-pdf" : "5.3.x"
}
}
Note from OP: This is the answer I found, but If someone posts an answer that does not involve using a package.json file (this is just a test suite rather than a package and I don't want to publish it as a package), I'll mark that answer as accepted.

Can't run npm install in an Ember CLI application?

I am setting up an Ember application on a new laptop. I installed node, npm through brew and I also have the Ember CLI. Within the Ember CLI app, I'm trying to do an npm install but when I do, I get this error in the terminal:
npm WARN package.json npm#1.4.21 Non-dependency in bundleDependencies: inherits
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.33
npm ERR! npm v2.1.11
npm ERR! code E404
npm ERR! 404 Not Found: expresss
npm ERR! 404
npm ERR! 404 'expresss' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'ember-cli'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Nagarjun/Code/sumo-list/web-client/npm-debug.log
I can't run my projects until this is resolved. What am I missing? I even Googled but couldn't find anything for expresss.
My guess is 'expresss' (with an extra s) is a package on npm that was pulled. The dependency was in fact listed in the package.json file for ember-cli but I don't think anyone ever noticed it until later versions.
Proof: https://github.com/stefanpenner/ember-cli/blob/ec8a6ab898599746bddbb8f72f7633c29f0ee95b/package.json#L58
I was able to resolve this issue by uninstalling node and npm completely using brew. Then, installing node.js using the package from nodejs.org. Now, my npm version is 1.4.28. Looks like the issue was caused by the newer npm 2.1.10. Not sure why brew automatically picks up the new npm.
Look in your package.json dependencies section. Looks like a typo.
I faced the same issue but it got fixed by running sudo npm install -g ember-cli

Resources