npm ERR! must provide string spec - node.js

I'm having this error since a while, in this case, the problem occur executing the following command.
npx create-react-app my-app
Actually, it happens with any npm commands as well, I tried deleting package.json, changing npm versions and yet didn't work, so I'm here asking for help.
This is the entire error:
C:\Users\c>npm install
npm ERR! must provide string spec
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\c\AppData\Local\npm-cache\_logs\2022-01-28T16_50_23_009Z-debug.log
Version of npm and node:
node --version
v16.13.2
npm --version
8.3.2

I had the same issue, it was a missing version in my package.json
look like mistakenly I removed some text
"dependencies":{
"angular/cli" :"{}"
}

try to update your npm: npm upgrade
then: npm clean cache

Following, i'm in the exact same position. Tried changing the NodeJS version using NVM and now some of the commands work (npm -v shows im running 8.1.0) but npm update and npm/npx create-react-app give me an " ERR! must provide string spec " !

I faced this same issue yesterday.
This is what I did to resolve it:
Uninstalling node entirely and removing node_modules and package.lock.json from the project directory.
Install node afresh and run npm install in your project directory.

I tried to reactivate an old project which had packages noted down differently then usual in package.json. They had an id and locator parameter, like:
"ImagePicker": {
"id": "ImagePicker",
"locator": "https://github.com/dhavalsoni2001/ImagePicker.git"
}
After removing / replacing them by version numbes, i could install.

Related

npm i not working? npm ERR! Unexpected token '.'

My npm install seems to have stopped working out of nowhere, regardless of if i do npm i or npm install I keep getting an error saying npm ERR! Unexpected token '.' The other npm commands seem to be working perfectly but I can't install any modules because of this error. I'm using npm 8.7.0 and node v14.18.1
The simplest solution I could find and what worked for me was completely removing and unisntalling everything to do with nodejs and npm from my laptop. I then reinstalled it back with no issues and am able to use the command now.
As mentioned in one of the answers, try deleting the node_modules folder and package.lock.json. Use
sudo npm install
And if that doesn't work, what I would suggest is that you use yarn. If you don't know what yarn is, it's just a package manager like node.
You can install yarn by using the following command:
npm install -g yarn
After this make sure all the node modules and package.lock.json is deleted. Now run the command
yarn install
Hopefully, this will fix your issue.

npm Install error- node modules but no package-lock.json

I'm getting an error with my npm install and would love some help/advice.
ELIFECYCLE
ENOENT
spawn bash
yorkie#2.0.0 install `node bin/install.js`
spawn bash ENOENT
Failed at the yorkie#2.0.0 install script
This is probably not a problem with npm. There is likely additional logging output above.
My node path is set in my environmental variables. My node version is 10.24.1 and npm version is 6.4.1
I am using nvm for windows to manage versions.
Whenever I run npm install I get this error, and node modules is created, but package-lock is not.
I have deleted node modules and ran npm cache clear with no success.
Any tips appreciated!
Try and run the following command.
npm install --registry=https://registry.npm.taobao.org
If that doesn't work, see the following Issues page on GitHub.
yorkie#2.0.0 error
EDIT: Just noticed, you should update your Node.js version. It is on v10 and the current LTS version (at the time posted) is v16. This is just a suggestion, although it might solve your issue.
This solved it for me!
npm config delete script-shell
Source: https://stackoverflow.com/a/46006249/15787997

npm ERR! Cannot read properties of null (reading 'pickAlgorithm')

iam getting below error with npm while creating react app
npm ERR! Cannot read properties of null (reading 'pickAlgorithm')
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Nagamanickam\AppData\Local\npm-cache_logs\2021-11-18T12_01_45_525Z-debug.log
my npm version is 8.1.4 and i solve this problem by running :
npm cache clear --force
I resolved it by deleting node_modules and package-lock.json and run npm install again.
solved with npm i --legacy-peer-deps on react-native version .70
Just run these 2 commands :
npm cache clear --force
npm install
Probably it's a project that works with Yarn and not NPM.
Try Yarn instead of NPM.
yarn install
and then you can do
yarn start
or
npm start
Your dependency tree may be broken (due to incompartible peer dependencies) you can try running npm install with --legacy-peer-deps or --force to bypass this issue for the mean time.
I was getting this error from an old branch that had a previous version of node/npm. using the correct version of node helped in my case.
In my case the file .npmrc was corrupt. After deleting it everything worked.
I was getting the same error, but I was able to resolve it by the below described method:
Go to folder -> Local > npm-cache and delete all contents of the npm-cache.
try again with npm command, it should work now.
I solved this by update npm from 6.x to 8.5x, then run npm cache clear --force, npm install, however, it has to change the nodejs from 14 to 17, my env is macOS m1 pro.
In my case i updated npm via:
npm update -g npm
After it, everything worked fine.
Don't know why, i didn't expect it.
I solved deleting node_modules and running this command:
npm cache clear --force

Why am I getting error "No valid versions available for undefined" while installing create-react-app

I'm trying to install React through command prompt. NodeJS is already installed.
When I try to run this command:
npm i -g create-react-app
It is displaying error as shown below:
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xyz\AppData\Roaming\npm-cache\_logs\2019-12-10T10_51_39_2222-debug.log
Sometimes this can happen when you are using a private NPM registry / proxy registry and it has corrupted metadata. I've seen this happen with Sonatype Nexus 3 - there were corresponding error messages in the server logs.
Are you sure you have the right Node version? Try updating NodeJS or try running: npx create-react-app my-app
you should check this out issue.
If the problem still exist, please check your versions with this:
npm -v
node -v
For me this error came up because I had a version number that did not exist for a package I wanted.

Error " ERR_OUT_OF_RANGE" when using npm install

I tried to create a new NodeJs project, when i ran "npm init" the package.json was created successfully but when I tried to run "npm install express" it showed "npm ERR! code ERR_OUT_OF_RANGE". I am not able to run npm install without getting this error.
I tried to install other packages, i tried sudo, and I removed npm/node and reinstalled nvm/node but it is still the same.
Thank you for your help !
npm install express
npm ERR! code ERR_OUT_OF_RANGE
npm ERR! The value of "err" is out of range. It must be a negative integer. Received 536870212
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2019-09-18T14_49_07_222Z-debug.log
The issue is a mismatch between your versions of Node and NPM.
This can occur when one is updated without the other.
To prevent these issues, use nvm to manage your Node version:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
# Example: Selecting Node v13
# For complete list of available versions run `nvm ls-remote`
nvm install 13
nvm use 13
This will select matching versions of Node and NPM.
This error was caused by a the most recent version of node which was 12.10.0, when I installed and used the 10.16.0 version of node, the error was gone.
i ran into something very similar with react native - metro and it seems I just had to deactivate my firewall LULU.

Resources