Whenever i do anything node relates whether it be npm install, starting a .js script or even installing modules i get this error:
'npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'through2'
i tried deleting node and reinstalling but still get it.
it randomly happened to, it seemed like out of the blue. any help would be great as this is a constant problem in my work.
If you delete your node_modules folder and try npm i it should work.
Also, if you are using gulp I think you can find your answer here cannot find module through2 while installing gulp
whatever module is missing, try using
npm install <module-name>#latest
even if this doesn't work there is another manage packager as npm known as yarn.
Try using it. Then by yarn it will be
yarn add <module-name>
it worked for me hope it works for you.
Related
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.
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.
I am getting this error while running npm start on my CRA app. I tried uninstalling and installing webpack. Only thing that works is,
creating a ".env" file at the root with SKIP_PREFLIGHT_CHECK=true.
`
hello#0.1.0 start C:\Users\USER\Desktop\MyReact\REACT_HOOKS\hello
react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App
requires a dependency:
"webpack": "4.42.0"
Don't try to install it manually: your package manager
does it automatically.
However, a different version of webpack was detected higher up in the tree:
C:\Users\USER\node_modules\webpack (version: 4.43.0)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
Delete node_modules in your project folder.
Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
Run npm install or yarn, depending on the package
manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
Check if C:\Users\USER\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
Try running npm ls webpack in your project folder. This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in
case you want to proceed anyway.
P.S. We know this message is long but please read the steps above 🙂 We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello#0.1.0 start: react-scripts start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
`
Ok, I ran npm uninstall -g webpack it didn't do anything.
then I ran both
npm uninstall -g webpack
npm uninstall webpack
and it's not showing the error anymore.
so apparently
npm uninstall webpack
worked.
Probably the issue was caused by a manual download of webpack.
I ran npm uninstall webpack, delete package.lock.json, and then run yarn.
If you prefer npm, then instead of running yarn , you run npm install.
This will re-install webpack the right way in the dependency tree.
Sorry for the following wall of text.
So I've been using someone else's meteor app. (they open sourced it) It's currently un-built and I've been running it on dev-mode. It's a lot slower than expected and users are having issues connecting to my local machine. So I'm attempting to deploy the app by following: https://guide.meteor.com/deployment.html#deploying.
So I've been getting errors when trying to run npm i. My dad recommended me to run npm cache verify and try again, then npm cache clean as a last resort. Neither worked and I've still am getting errors. Although as soon as I tried again after running npm cache verify the error amount skyrocketed. I unfortunately don't have the errors I got before I cleared my cache but I have the current logs here: https://pastebin.com/dAcRnE9v But here is a snapshot:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fibers#2.0.2 install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR! Failed at the fibers#2.0.2 install script.
I honestly don't have any idea what todo. I've never worked with meteor before, nor the fibers module that's failing. I don't even know if this is the right place I should be asking for help.
I once had fibers npm package in my package.json which caused a similar error. Once I removed it everything built just fine.
You can't change Meteor's version of node - for compatibility reasons it bundles node/npm with Meteor to protect you. Just prefix all your npm/node commands with meteor like this:
meteor npm install
It won't use the node version (13.x) that you have installed
I am having an issue installing csvtojson. When I run npm install csvtojson I'm getting npm error tb.match is not a function. How do I solve this?
If you cant get to use NPM right away, try to use YARN and see if the dependencies will install
Removing the lock file AND the node_modules folder worked for me. Try to remove them and run again npm install.
Remove package.lock and run npm install is working for me.