I encounter this problem when am trying to install ganache-cli in my laptop (Kali Linux). The error that I came across is:
sudo npm install -g ganache-cli
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'encoding'
The debug log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', '-g', 'ganache-cli' ]
2 info using npm#5.8.0
3 info using node#v8.11.2
4 verbose npm-session 8012bd73873770d8
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for ganache-cli#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 /home/shirke
10 verbose Linux 4.15.0-kali2-amd64
11 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "ganache-cli"
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 ]
This error is bugging me a lot as am not able to do any work.
Welcome to SO.
You need to manually install encoding using below command to make it work
npm install encoding
Related
I'm trying to use to npm to install anything, and nothing works. I get the error code 'MODULE_NOT_FOUND' and 'cannot find module 'readable-stream/transform''.
I've tried uninstall and reinstalling nodejs. In the process I lost nodemon and now I can't even reinstall it because of this error.
This is the log of the error from Appdata/Roaming/npm-cache/_logs
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'i' ]
2 info using npm#6.9.0
3 info using node#v10.16.0
4 verbose stack Error: Cannot find module 'readable-stream/transform'
4 verbose stack at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
4 verbose stack at Function.Module._load (internal/modules/cjs/loader.js:562:25)
4 verbose stack at Module.require (internal/modules/cjs/loader.js:690:17)
4 verbose stack at require (internal/modules/cjs/helpers.js:25:18)
4 verbose stack at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\mississippi\node_modules\through2\through2.js:1:17)
4 verbose stack at Module._compile (internal/modules/cjs/loader.js:776:30)
4 verbose stack at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
4 verbose stack at Module.load (internal/modules/cjs/loader.js:653:32)
4 verbose stack at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
4 verbose stack at Function.Module._load (internal/modules/cjs/loader.js:585:3)
4 verbose stack at Module.require (internal/modules/cjs/loader.js:690:17)
4 verbose stack at require (internal/modules/cjs/helpers.js:25:18)
4 verbose stack at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\mississippi\index.js:5:26)
4 verbose stack at Module._compile (internal/modules/cjs/loader.js:776:30)
4 verbose stack at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
4 verbose stack at Module.load (internal/modules/cjs/loader.js:653:32)
5 verbose cwd C:\Users\adamn\Desktop\Development\adamNode
6 verbose Windows_NT 10.0.17134
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
8 verbose node v10.16.0
9 verbose npm v6.9.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'readable-stream/transform'
12 verbose exit [ 1, true ]
npm install should install different modules but I just get errors instead.
I had the same problem, but it solved by taking long hours of googling.
The problem is a package named mississippi is outdated and cause the problem!
From you error log:
4 verbose stack at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\mississippi\node_modules\through2\through2.js:1:17)
Where you can some useful things about it: github#1809
Just remove the 'C:\Program Files\nodejs\node_modules\npm\node_modules' folder, unInstall the nodejs and npm and reinstall them again!
Additional information for Arch Linux users, that modules are not located under '/opt/local/lib/node_modules' as other distributions or installation mechanism, And so remove and installation of the nodejs and npm will not solve the problem!
sudo rm -rf /usr/lib/node_modules
sudo pacman -S nodejs npm
I'm working through a tutorial about learning npm, but am having trouble with even the simplest instructions.
Basically the first instruction given was to install the node-dev package globally, using the Terminal line: sudo npm install -g node-dev. Unfortunately, this spits out an error:
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './access-error.js'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/samlegros/.npm/_logs/2019-02-26T00_36_39_572Z-debug.log
After some Googling and digging, nothing seemed to work for my case. So I thought I would try fully removing and reinstalling npm to start with a clean slate (I had worked with npm a while back, so maybe something messed up back then).
Even going through the official npm-removal documentation, I still get a similar error! I can't even remove npm properly...
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module './access-error.js'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/samlegros/.npm/_logs/2019-02-26T00_38_40_865Z-debug.log
Any help would be deeply appreciated. I've tried several npm tutorials over the months and they always result in errors that I just never know how to overcome, very discouraging :(
(error log, if that helps)
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'uninstall',
1 verbose cli 'npm',
1 verbose cli '-g' ]
2 info using npm#6.8.0
3 info using node#v8.11.1
4 verbose stack Error: Cannot find module './access-error.js'
4 verbose stack at Function.Module._resolveFilename (module.js:547:15)
4 verbose stack at Function.Module._load (module.js:474:25)
4 verbose stack at Module.require (module.js:596:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/install/exists.js:4:19)
4 verbose stack at Module._compile (module.js:652:30)
4 verbose stack at Object.Module._extensions..js (module.js:663:10)
4 verbose stack at Module.load (module.js:565:32)
4 verbose stack at tryModuleLoad (module.js:505:12)
4 verbose stack at Function.Module._load (module.js:497:3)
4 verbose stack at Module.require (module.js:596:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/install/check-permissions.js:8:14)
4 verbose stack at Module._compile (module.js:652:30)
4 verbose stack at Object.Module._extensions..js (module.js:663:10)
4 verbose stack at Module.load (module.js:565:32)
5 verbose cwd /path/to/tutorial/
6 verbose Darwin 18.2.0
7 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "uninstall" "npm" "-g"
8 verbose node v8.11.1
9 verbose npm v6.8.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module './access-error.js'
12 verbose exit [ 1, true ]
I simply removed Node.js from my Mac and reinstalled it, that worked.
Command used to remove Node.js: sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
Everything works great now.
I did not update npm for a while. My version is 5.8.0
the current is 6.4.1
I tried this command, but did not work:
$ npm install npm#latest -g
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'y18n'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\erjan222\AppData\Roaming\npm-cache\_logs\2018-09-16T14_16_55_797Z-debug.log
Googling for similar topic on npm forum did not help -
y18-n
The debug.log file has this:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\erjan222\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'npm#latest',
1 verbose cli '-g' ]
2 info using npm#5.8.0
3 info using node#v8.10.0
4 verbose stack Error: Cannot find module 'y18n'
4 verbose stack at Function.Module._resolveFilename (module.js:547:15)
4 verbose stack at Function.Module._load (module.js:474:25)
4 verbose stack at Module.require (module.js:596:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (C:\Users\erjan222\AppData\Roaming\npm\node_modules\npm\node_modules\cacache\lib\util\y.js:4:14)
4 verbose stack at Module._compile (module.js:652:30)
4 verbose stack at Object.Module._extensions..js (module.js:663:10)
4 verbose stack at Module.load (module.js:565:32)
4 verbose stack at tryModuleLoad (module.js:505:12)
4 verbose stack at Function.Module._load (module.js:497:3)
4 verbose stack at Module.require (module.js:596:17)
4 verbose stack at require (internal/module.js:11:18)
4 verbose stack at Object.<anonymous> (C:\Users\erjan222\AppData\Roaming\npm\node_modules\npm\node_modules\cacache\lib\entry-index.js:13:11)
4 verbose stack at Module._compile (module.js:652:30)
4 verbose stack at Object.Module._extensions..js (module.js:663:10)
4 verbose stack at Module.load (module.js:565:32)
5 verbose cwd C:\Users\erjan222\Desktop
6 verbose Windows_NT 6.1.7601
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\erjan222\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "npm#latest" "-g"
8 verbose node v8.10.0
9 verbose npm v5.8.0
10 error code MODULE_NOT_FOUND
11 error Cannot find module 'y18n'
12 verbose exit [ 1, true ]
I recommend that you try install y18n first then upgrade npm like this:
npm install y18n#4.0.0 -g
npm install npm#latest -g
Or install 8.12.0 LTS from nodejs
First, upgrade your npm to latest version and Then install y18n module using this commands
npm i -g npm-upgrade
npm i y18n
If you want to ignore particular module from npm update,refer this link answer.
npm install: Is there a way to ignore a particular dependency
For anything I try install with npm it returns the same error: Cannot find fstream module. The funny thing is that 'fstream' is into my NodeJS folder (C:/Program Files/nodejs/node_modules/npm/node_modules)
I've tried to reinstalling, uninstalling and reinstalling, installing others nodejs versions, restarting the system and nothing!
Here is a log example trying to install firebase tools
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Checho\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'firebase-tools' ]
2 info using npm#5.3.0
3 info using node#v8.5.0
4 verbose npm-session 1f5a9f5441b96d8f
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 verbose stack Error: Cannot find module 'fstream'
7 verbose stack at Function.Module._resolveFilename (module.js:527:15)
7 verbose stack at Function.Module._load (module.js:476:23)
7 verbose stack at Module.require (module.js:568:17)
7 verbose stack at require (internal/module.js:11:18)
7 verbose stack at Object.<anonymous> (C:\Users\Checho\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\entry.js:14:15)
7 verbose stack at Module._compile (module.js:624:30)
7 verbose stack at Object.Module._extensions..js (module.js:635:10)
7 verbose stack at Module.load (module.js:545:32)
7 verbose stack at tryModuleLoad (module.js:508:12)
7 verbose stack at Function.Module._load (module.js:500:3)
7 verbose stack at Module.require (module.js:568:17)
7 verbose stack at require (internal/module.js:11:18)
7 verbose stack at Object.<anonymous> (C:\Users\Checho\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\entry-writer.js:5:13)
7 verbose stack at Module._compile (module.js:624:30)
7 verbose stack at Object.Module._extensions..js (module.js:635:10)
7 verbose stack at Module.load (module.js:545:32)
8 verbose cwd C:\Users\Checho\AppData\Roaming\npm-cache\_logs
9 verbose Windows_NT 10.0.14393
10 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Checho\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "firebase-tools"
11 verbose node v8.5.0
12 verbose npm v5.3.0
13 error code MODULE_NOT_FOUND
14 error Cannot find module 'fstream'
15 verbose exit [ 1, true ]
I solved it!
Just copying the C:\Program files\nodejs\node_modules\npm\node_modules directory into C:\Users\{ my-user }\AppData\Roaming\npm\node_modules and replacing all their files.
Is there where the globally files are located. But in last update of npm something wrong must have happened.
npm error when I try to build the React Native environment with Mac.
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'react-native' ]
2 info using npm#2.15.9
3 info using node#v4.6.0
4 verbose stack Error: Cannot find module './spawn'
4 verbose stack at Function.Module._resolveFilename (module.js:325:15)
4 verbose stack at Function.Module._load (module.js:276:25)
4 verbose stack at Module.require (module.js:353:17)
4 verbose stack at require (internal/module.js:12:17)
4 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:6:13)
4 verbose stack at Module._compile (module.js:409:26)
4 verbose stack at Object.Module._extensions..js (module.js:416:10)
4 verbose stack at Module.load (module.js:343:32)
4 verbose stack at Function.Module._load (module.js:300:12)
4 verbose stack at Module.require (module.js:353:17)
4 verbose stack at require (internal/module.js:12:17)
5 verbose cwd /Users/BigGIfts
6 error Darwin 15.6.0
7 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "react-native"
8 error node v4.6.0
9 error npm v2.15.9
10 error code MODULE_NOT_FOUND
11 error Cannot find module './spawn'
12 error If you need help, you may report this error at:
12 error <https://github.com/npm/npm/issues>
13 verbose exit [ 1, true ]
The correct way to build the react-native:
npm install -g react-native-cli
If you get an error like:
Cannot find module 'npmlog'
Try installing npm directly: curl -0 -L https://npmjs.org/install.sh | sudo sh
Note: when the error cannot find ... is anywhere in the error log and you did install it, it's probably either in the wrong directory or you haven't installed it yet.
Hope this helps you out ;)