Module not found if installing a package in global with pnpm - pnpm

I am trying to install prettier with pnpm install prettier -g, and when I tried to run it in the terminal, it gives me the following error:
node:internal/modules/cjs/loader:944
throw err;
^
Error: Cannot find module '/Users/hugosum/pnpm-global/5/node_modules/prettier/bin-prettier.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
at Function.Module._load (node:internal/modules/cjs/loader:774:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
When I do which prettier, it gives me /usr/local/bin/prettier. How can I further debug and solve this issue?

Solved this by cleaning up duplicating binary in /usr/local/bin

Related

Yarn installed through brew but when I find yarn version it came a error

yarn -v
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module '/Users/sadeepa/.yarn/releases/yarn-3.3.1.cjs'
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.12.1
Any one please help? Thanks
I want to reinstall yarn because of some problems then I tried to uninstall all the yarn things and install again so I get errors
Hi I have got the same problem
ubuntu#ip-xxx-xx-x-xxx:~/yarn
node:internal/modules/cjs/loader:988
throw err;
^
Error: Cannot find module '/home/ubuntu/.yarn/releases/yarn-3.3.1.cjs'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
and I found the file named .yarnrc.yml and remove it
ubuntu#ip-xxx-xx-x-xxx:~$ cat .yarnrc.yml
yarnPath: .yarn/releases/yarn-3.3.1.cjs
ubuntu#ip-xxx-xx-x-xxx:~$ rm .yarnrc.yml
ubuntu#ip-xxx-xx-x-xxx:~$ yarn
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.07s.
ubuntu#ip-xxx-xx-x-xxx:~$ yarn -v
1.22.19

Failed to get yarn configuration while installing Jupyter Lab in Cygwin

I am trying to install some extensions for jupyterlab in Cygwin. So I type, for example, jupyter labextension install #jupyter-widgets/jupyterlab-manager in the Cygwin command prompt. But I get an error. Here's the log:
Fail to get yarn configuration. internal/module/cjs/loader.js:968
throw err;
^
Error: Cannot find module 'C:\home\<user>\<path_to_venv>\lib\python3.8\site-packages\jupyterlab\staging\yarn.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND,
requireStack: []
}
Fail to get yarn configuration. internal/module/cjs/loader.js:968
throw err;
^
Error: Cannot find module 'C:\home\<user>\<path_to_venv>\lib\python3.8\site-packages\jupyterlab\staging\yarn.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND,
requireStack: []
}
An error occured.
OSError: [Errno 16] Device or resource busy: '/tmp/tm1da390j3'
See the log file for details: /tmp/jupyterlab-debug-mgr2ux9k.log
I understand the error: instead of looking for C:\cygwin64\home\<user>\<path_to_venv>\lib\python3.8\site-packages\jupyterlab\staging\yarn.js the installation manager looks for C:\home\<user>\<path_to_venv>\lib\python3.8\site-packages\jupyterlab\staging\yarn.js. I just don't know how to fix it. Maybe I need to edit some configuration files. I would be very grateful for your help.

Cannot find module 'heroku-run'

Tried to run heroku logs to check an error, got this:
$ heroku run rake db:migrate
! Error in heroku-run:
! Cannot find module 'heroku-run'
! See ~/.heroku/error.log for more info.
Now every time I run a heroku command I get that message. Tried updating heroku, no change. Tried installing heroku-run, not a gem. Checked the error log and it just says the same thing:
2016/04/09 22:51:45 Error: Cannot find module 'heroku-run'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/tmp/heroku-script-021789235:34:14)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
For ubuntu I had to:
sudo aptitude purge heroku heroku-toolbelt
rm -rf ~/.heroku
wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
before things started worked again.
I believe there was an issue with the heroku-toolbelt client for osx, run heroku update to get a fixed version.

How to solve error message "Cannot find module 'abbrev'

My question is very similar to How do I resolve "Cannot find module" error using Node.js? but I cannot solve my problem using the information provided in the answer given.
I try to run the UNCSS grunt plugin, but when I try to install it (npm install grunt-uncss --save-dev), I get the following error:
$ npm install grunt-uncss --save-dev
module.js:340
throw err;
^
Error: Cannot find module 'abbrev'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/Cellar/node/0.10.20/lib/node_modules/npm/node_modules/nopt/lib/nopt.js:10:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
Based on the answer mentioned above, I tried installing this 'abbrev' module, both in project folder, and globally, but this yields the exact same error :(
npm install -g abbrev
module.js:340
throw err;
^
Error: Cannot find module 'abbrev'
at Function.Module._resolveFilename (modu
(ETCETERA)
Main question: How to I solve this error?
Sub questions:
1) I wonder, is this a RUBY error or a NODE.JS error? I noticed 'abbrev' is also a Ruby command...?
2) Or, could this problem have arisen because I tried to solve the bus error: 10 ? (http://shoogledesigns.com/blog/blog/2014/01/13/gruntjs-running-watch-task-waiting-bus-error-10/)
I hope this question doesn't sound too obvious. I'm a front-end developer, but far from a command-line guru!
For me it has been solved by updating npm itself:
sudo npm install -g npm
Solution: re-installing node.js, as I mention in my last comment.
Tell-tale was the very same error-message every time I ran NPM.
Removing node_modules and then reinstalling the modules specified in my package.json worked for me.
I did that by runnning the following commands:
rm -rf node_modules
npm install
Neither one of the other two answers solved it for me, but both together did.
I had a very similar issue. Removing the entire node_modules folder and re-installing it's worked for me. I did that by running the following commands:
rm -rf node_modules
npm install
Windows user here. I tried re-installing Node.js (using installer) and it did not help. I had to run the rm -rf node_modules to remove the "node_modules" folder at the location listed in the error (midway down).
In the OP example it was at
Object. (/usr/local/Cellar/node/0.10.20/lib/node_modules/
It was something like C:\Users\nick\AppData\Roaming\npm\node_modules

npm install successfully but node web.js erros w: "Error: Cannot find module"

I'm working to get node running on a new mac. I downloaded the installed at http://nodejs.org/
I then git cloned my node repo, ran npm install and npm update, and then node web.js which then errors with:
$ node web.js
Error: Cannot find module '/Users/me/Sites/mysite-node/node_modules/pg/lib/native/../../build/default/binding'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/Users/me/Sites/mysite-node/node_modules/pg/lib/native/index.js:12:12)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
I'm new to node, any ideas or suggestions on where to look? Thanks
You need to install the postgresql libraries on your machine. For example under Fedora you'd:
yum install postgresql.x86_64
yum install postgresql-server.x86_64
If you already had pg install you'd need to rebuild it:
npm rebuild pg
Then to verify everything is working at the terminal type:
node
Then in the node REPL type:
var pg = require('pg').native
And you shouldn't get an error
The Error shows that npm installation of the pg module has not built the native bindings properly. Modify your code as follows:
//var pg = require('pg').native;
var pg = require('pg');

Resources