npm cannot find module 'encoding'
So I encounter this kind of problem in npm. I'm using VSCode, btw my laptop is newly formated my OS is Ubuntu. The error that I came across when I install something is:
npm ERR! code MODULE_NOT_FOUND npm ERR! cannot find module 'encoding' // Log 0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', '-g', 'jshint' ] 2 info using email@example.com 3 info using firstname.lastname@example.org 4 verbose npm-session 94ee8611aa9e8514 5 silly install loadCurrentTree 6 silly install readGlobalPackageData 7 silly fetchPackageMetaData error for jshint@latest Cannot find module 'encoding' 8 verbose stack Error: Cannot find module 'encoding' 8 verbose stack at Function.Module._resolveFilename (module.js:547:15) 8 verbose stack at Function.Module._load (module.js:474:25) 8 verbose stack at Module.require (module.js:596:17) 8 verbose stack at require (internal/module.js:11:18) 8 verbose stack at Object.<anonymous> (/usr/share/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/body.js:13:17) 8 verbose stack at Module._compile (module.js:652:30) 8 verbose stack at Object.Module._extensions..js (module.js:663:10) 8 verbose stack at Module.load (module.js:565:32) 8 verbose stack at tryModuleLoad (module.js:505:12) 8 verbose stack at Function.Module._load (module.js:497:3) 8 verbose stack at Module.require (module.js:596:17) 8 verbose stack at require (internal/module.js:11:18) 8 verbose stack at Object.<anonymous> (/usr/share/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:15:14) 8 verbose stack at Module._compile (module.js:652:30) 8 verbose stack at Object.Module._extensions..js (module.js:663:10) 8 verbose stack at Module.load (module.js:565:32) 9 verbose cwd /opt/lampp/htdocs/My Website #1 10 verbose Linux 4.18.0-parrot8-amd64 11 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "jshint" 12 verbose node v8.11.2 13 verbose npm v5.8.0 14 error code MODULE_NOT_FOUND 15 error Cannot find module 'encoding' 16 verbose exit [ 1, true ]
I tried reinstalling Node.js/npm but still not working.
When reading through your verbose output you can read in line 7:
silly fetchPackageMetaData error for jshint@latest Cannot find module 'encoding'
You obviously tried to install jshint globally via npm () as stated here:
verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "jshint"
This could be dependency issues with your node and your npm version..
Or conflicts in node_modules folder. Good idea to make sure it's clean, try:
rm -rf node_modules && npm install
Also check your NODE_PATH in case npm tries installing it into a location that's not your NODE_PATH..
I just tried on debian with node v8.11.1 and npm 6.0.1 and it worked fine for me..
Have you tried it with these or other versions of node and npm (using LTS)?
NPM global install "cannot find module", npm ERR! email@example.com build: gulp build npm ERR! Error: Cannot find module 'C:\Users\Lenovo\Desktop\sample website with� I have this problem. I need to install node again or have other alternative. See my code here: C:\\Users\\micha\\Downloads\\mBlock-master\\mBlock-master>npm -v module.js:540 throw err; ^ Error: Cannot find module ‘C:\\Program Files\ odejs\ ode_modules\\npm\\bin\\npm-cli.js’ at Function.Module._resolveFilename (module.js:538:15) at Function.Module._load (module.js:468:25) at Function
If I understood your question you have some problem to install npm in your system.
try with these 2 steps
1.) run command
npm cache clean
2.) then remove the npm folder from the file structure and re-install npm
Missing modules when running npm run build or npm install � Issue , -v module.js:540 throw err; ^ Error: Cannot find module 'C:\Pro… find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js' It is possible you are missing a dependency that is needed from npm install, but if it says it cannot find the main file you are trying to run, then you are trying to run a file that does not exist. It is a common mistake. How to fix "Error: Cannot find module" You need to double check you are running the correct file from the correct directory.
Possible dependency missing,
rm -rf node_modules package-lock.json && npm install
if you are mac, linux user and you are having privileges issues
rm -rf node_modules package-lock.json && npm install
NPM Cannot find module - support, I wrote a module which I published to npm a moment ago So it installs fine from the command directory being empty. No idea how to resolve� I am using the same version of npm/node. Sometimes, it is like npm is "lost". What I suggest is : rm of your node modules (at least the one that is concerned) npm cache clean; run "npm install" several times, until all dependencies are resolved and no message are displayed
Error:NPM global install “cannot find module”, Even though I have installed my npm package globally, I receive the following error : Error: Cannot find module 'color' at Function.Module. When installing a module from a local directory like this: npm install ../some-module If the installed module does not have a ./index.js as the entry point, then your package cannot find the module. How can the CLI team reproduce the problem? First clone a module from it's source that qualifies for this problem, for example:
Node.JS: Error Cannot find module [SOLVED] – imcodebased, It is possible you are missing a dependency that is needed from npm install , but if it says it cannot find the main file you are trying to run, then� Find the row with variable Path and click it. Click edit which will open a window titled Edit evironment variable. Here if you find ; C:\Program Files odejs ode_modules\npm\bin. select it, and click edit button to your right, then edit the field to the path where you have the nodejs folder, in my case it was just shortening it to :
How to solve "Error: Cannot find module '*.js'" with Node.js , You're telling node to execute a script called run , with index.js being an argument to run : Usage: node [options] [ -e script | script.js� Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR!
- Is this happening only for
encodingpackage or its is the same for all? As you said you formatted your os, I suspect it is for any package. I would also ask you to check
npmrc. Can you post those details as well?
- Not sure, but may be you need to install that module first? Did it worked before or it is new project?
- I tried to install other node packages but didn't work, same error. rm -rf node_modules && npm install I tried the command in terminal still not working.
- What i meant is have you tried to install other versions of node/npm. Maybe there's a conflict with your node version and the npm installer..
- Nope. But I remember that I recently updated my build-essentials maybe it affect the node/npm
- I've tried it with build-essential 12.3 with no issues, i would recommend you give it a shot at installing the above mentioned versions to boil the problem down a bit further. Check your NODE_PATH as well as mentioned in my answer..
- So... I tried anything else that you've said didn't work. But my professor already got a solution which is to reinstall linux, we've tried many possible solutions but none of them worked so he recommend to re-install linux and now it's working fine.
npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use 'npm install --cache /tmp/empty-cache' to use a temporary cache instead of nuking the actual one.
npm ERR! If you're sure you want to delete the entire cache, rerun this command with --force.