Error: Cannot find module when trying to find yarn --version. It thinks it's in anaconda3 - npm

I've installed yarn via npm through npm install --global yarn.
When I try to check the version it's looking for it in an anaconda3 related path which is weird. This conflicting path doesn't show up in the system or user environment variables. I checked for the correct path of yarn and it is in my user environment variables. So this conflicting path seems to be the issue?
I'm not sure how to address this because I believe there was some specific setup when initializing vscode to recognize anaconda.
$ yarn --version
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module 'C:\Users\deerr\anaconda3\Library\c\Users\deerr\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js'
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: []
}

Related

Yarn Install Error: Package subpath error

I am currently working on a project following the documentation in this github repo.
github repo
I first clone the repo into a folder. I then cd into the folder and do a run yarn install to get all dependencies. I get the following error. I have node v17.2.0 installed.
(base) Eddys-MacBook-Pro:avalanche-wallet-sdk eddyarce$ yarn install
yarn install v1.22.17
warning ../../../../../package.json: No license field
[1/5] 🔍 Validating package.json...
[2/5] 🔍 Resolving packages...
success Already up-to-date.
$ husky install && yarn build:prod
husky - Git hooks installed
yarn run v1.22.17
warning ../../../../../package.json: No license field
$ rollup -c --environment BUILD:production
Error loading `tslib` helper library.
[!] Error: Package subpath './package.json' is not defined by "exports" in /Users/eddyalvarado_1/Documents/GitHub/plasma-wallet-web3/js/avalanche-wallet-sdk/node_modules/rollup-plugin-typescript2/node_modules/tslib/package.json
Error: Package subpath './package.json' is not defined by "exports" in /Users/eddyalvarado_1/Documents/GitHub/plasma-wallet-web3/js/avalanche-wallet-sdk/node_modules/rollup-plugin-typescript2/node_modules/tslib/package.json
at new NodeError (node:internal/errors:371:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:429:9)
at packageExportsResolve (node:internal/modules/esm/resolve:683:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/eddyalvarado_1/Documents/GitHub/plasma-wallet-web3/js/avalanche-wallet-sdk/node_modules/rollup-plugin-typescript2/src/tslib.ts:11:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
https://github.com/ezolenko/rollup-plugin-typescript2/issues/286
Upgrade your tslib version (>=0.31.0) or downgrade your node version (<17.0.0)

React Native: expo start caused throw err: Cannot find module

PLease help, I started a new React Native app. I followed the React Native instruction on how to set up dev env. https://reactnative.dev/docs/environment-setup
I installed the latest Node. Then in my project folder:
I ran '''npm install -g expo-cli'''
then, 'expo init AwesomeProject'
cd AwesomeProject
npm start
When I did npm start, that's when I saw this error message. I tried to search online for solutions. I reinstall Node, add a new path for Node, nothing seems to help. Any suggestions would be greatly appreciated.
UPDATE*. Steps to resolve above issue, update Node.js, errors show up when using Git Bash, switch to command prompt, then do 'expo start' instead of 'npm start', now it works.
Git Bash:
$ expo start
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Users\wendy\node_modules\expo-cli\bin\expo.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

internal/modules/cjs/loader.js:584 issue

I got a problem when I input any npm cmd, it says
internal/modules/cjs/loader.js:584
Operating System: Windows 10 64bit
What shall I do to solve this issue?
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'E:\FED\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
For many people on Mac (not sure about Windows/Linux), the solution is:
Delete node_modules and package-lock.json, then run $ npm install again.
You can also try updating your version of node.
Check version with $ node -v,
install with $ sudo n stable
I was having a similar error but it was because I hadn't had my node_modules(the ones you deleted ) file open in the file I was working on, even though I had run npm Install.
my Error was
Cannot find module _resolveFilename
If you build and deploy another place at a later time for example in an docker image, it may help to bundle the dependencies that the loader cannot find in package.json. Then the packaged are bundled and the loader can find them.
"bundledDependencies": [ "express", "express-http-proxy", ],
"dependencies": { ...}
Before starting any project you have to write this command npm init --yes

Error in installing restify using npm

I am trying to install restify but I am getting this error.
c:\Program Files\nodejs>npm install --save restify
module.js:471
throw err;
Error: Cannot find module 'c:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
can someone help?
It's not a restify problem. Check your environment variables if they're pointing to your valid local NodeJS bin-directory. Thats the place where your "npm-cli.js" should be.
How to set environment variables on different operating systems:
OSX:
Setting environment variables in OS X?
Windows:
https://www.computerhope.com/issues/ch000549.htm
Linux:
https://www.cyberciti.biz/faq/set-environment-variable-linux/

Express on NPM doesn't start application

Installed latest NPM v0.10.28
Then I installed express by
npm install express -g
Then I installed app as folows
express testExpress
cd testExpress && npm install
Then I ran following command to start server
DEBUG=testExpress ./bin/www
But it gives error
'DEBUG' is not recognized as an internal or external command,
operable program or batch file.
Also tried
node DEBUG=testExpress ./bin/www
Still gives error
module.js:340
throw err;
^
Error: Cannot find module 'C:\tmp\testExpress\DEBUG=testExpress'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
What mistake I am doing ? Please help.
You're trying to use Linux environment variable syntax on Windows.
You want
SET DEBUG=testExpress
bin\www