Yarn Install Error: Package subpath error - npm

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)

Related

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

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: []
}

How to fix Error: The project seems to require yarn but it's not installed

I just create this project with,
npm install --global yarn
vue create elecprog
yarn serve (-> error)
Also, I'm using VS Code terminal
PS D:\elcp\elecprog> yarn serve
yarn run v1.22.17
$ vue-cli-service serve
INFO Starting development server...
DONE Compiled successfully in 2889ms 오전 9:10:38
App running at:
- Local: http://localhost:[port]/
- Network: http://[myIp]:[port]/
ERROR Error: The project seems to require yarn but it's not installed.
Error: The project seems to require yarn but it's not installed.
at checkYarn (D:\elcp\elecprog\node_modules\#vue\cli-shared-utils\lib\env.js:46:43)
at exports.hasProjectYarn (D:\elcp\elecprog\node_modules\#vue\cli-shared-utils\lib\env.js:42:10)
at D:\elcp\elecprog\node_modules\#vue\cli-service\lib\commands\serve.js:312:34
at Hook.eval [as callAsync] (eval at create (D:\elcp\elecprog\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:44:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (D:\elcp\elecprog\node_modules\tapable\lib\Hook.js:18:14)
at Watching._done (D:\elcp\elecprog\node_modules\webpack\lib\Watching.js:287:28)
at D:\elcp\elecprog\node_modules\webpack\lib\Watching.js:209:21
at Compiler.emitRecords (D:\elcp\elecprog\node_modules\webpack\lib\Compiler.js:906:5)
at D:\elcp\elecprog\node_modules\webpack\lib\Watching.js:187:22
at D:\elcp\elecprog\node_modules\webpack\lib\Compiler.js:872:14
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS D:\elcp\elecprog>
In my case (OS: WINDOWS 11) installing yarn form official installer: https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable
form tab Alternatives
However this is only for Yarn 1.22.19 and current Yarn version you can check here:
https://github.com/yarnpkg/berry/releases

Cannot find module 'fs-extra' when testing with Truffle

I am reading the tutorial on Ethereum Pet Shop -- Your First DApp, everything seems ok until I test with truffle test with below error:
Error: Cannot find module 'fs-extra'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.call (/Users/.npm-global/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/external "fs-extra":1:18)
at r (/Users/.npm-global/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
[...]
Truffle v5.2.4 (core: 5.2.4)
Node v10.16.0
I have tried some suggestions as in Module is extraneous npm, but the Error: Cannot find module 'fs-extra' insists.
You need to add it to your package.json and install the package.
Either run
npm install --save fs-extra
The --save option will add it to the package.json for you.
Or add it manually to the package.json section dependencies
"dependencies": {
"fs-extra": "^9.1.0"
}
and then install it
npm install
Version 9.1.0 is the current version according to npmjs
fs-extra-package should be delivered as part of truffle and I would not recommend installing it to the project.
To fix it on Ubuntu follow these steps:
# stop apps/tools that using truffle - ganache-cli, etc.
# uninstall truffle
sudo npm uninstall -g truffle
# install truffle again
sudo npm install -g truffle
# check that fs-extra packaged installed
ls -lh /usr/local/lib/node_modules/truffle/node_modules | grep fs-extra

Unable to run local version of testcafe via npm link

Whenever I try to run a locally installed version of testcafe, I get the error Cannot find module '../testcafe/lib/cli'. Steps I've taken:
git clone <testcafe>, then cd to testcafe
npm install
npm link
cd to repo where my automated tests reside
npm link testcafe
Run testcafe <browser>
Results in
internal/modules/cjs/loader.js:796
throw err;
^
Error: Cannot find module '/Users/rcooper/testcafe/lib/cli'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Is there something else I need to do, to run a local version of this library?
You need to build the TestCafe package. Run npx gulp build before the npm link command.

"react-native init project" command not working

I am trying to create react native project with following command but getting error, Help me gyus:
react-native init Sample
Following error occurs:
This will walk you through creating a new React Native project in D:\React_Demos\Sample
Using yarn v1.17.3
Installing react-native...
yarn add v1.17.3
info No lockfile found.
[1/4] Resolving packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.npmjs.org/react-native: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888".
info If you think this is a bug, please open a bug report with the information provided in "D:\React_Demos\Sample\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Error: Command failed: yarn add react-native --exact
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:657:15)
at run (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:294:5)
at createProject (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)
at init (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5)
at Object. (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)
at Module._compile (internal/modules/cjs/loader.js:777:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:788:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12) {
status: 1,
signal: null,
output: [ null, null, null ],
pid: 10924,
stdout: null,
stderr: null
}
Command yarn add react-native --exact failed.
Here is the yarn.log file:
Arguments:
C:\Program Files\nodejs\node.exe C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js add react-native --exact
PATH:
C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\PuTTY\;C:\Users\sachin.salunkhe\AppData\Roaming\npm;C:\adb;C:\Program Files\Apache Software Foundation\apache-maven-3.5.4;\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Users\sachin.salunkhe\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\Users\sachin.salunkhe\AppData\Local\Android\Sdk\emulator\;C:\Program Files (x86)\Yarn\bin\;C:\Program Files\Apache Software Foundation\apache-maven-3.5.4\bin;C:\Program Files\Java\jdk1.8.0_181\;C:\Users\sachin.salunkhe\AppData\Local\Programs\Fiddler;C:\Users\sachin.salunkhe\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\sachin.salunkhe\AppData\Local\Yarn\bin
Yarn version:
1.17.3
Node version:
12.7.0
Platform:
win32 x64
Trace:
Error: https://registry.npmjs.org/react-native: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8888
at ClientRequest.onError (C:\Users\sachin.salunkhe\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:151950:17)
at Object.onceWrapper (events.js:291:20)
at ClientRequest.emit (events.js:203:13)
at Socket.socketErrorListener (_http_client.js:399:9)
at Socket.emit (events.js:203:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:77:11)
npm manifest:
{"name":"Sample","version":"0.0.1","private":true,"scripts":{"start":"node node_modules/react-native/local-cli/cli.js start"}}
yarn manifest:
No manifest
Lockfile:
No lockfile
First You Can Run This Command,
sudo npm install -g react-native-cli
then after run this command,
react-native init Sample
Make sure you have carried out this course.
choco install -y nodejs.install python2 jdk8 // If there is no choco, install it.
npm install -g react-native-cli
Download and install Android Studio // and setting Configure the ANDROID_HOME environment variable. and new SDK
react-native init AwesomeProject
First, remove node modules then install it again then install react-native cli. After that run init command.
I hope this is helpful for him.
1) Remove node_modules then update react native-cli with latest version.
2) npm install
3) react-native link
4) After that this command : react-native run-android
If you navigate to your npm folder before issuing the command, it should work, then you can always move the folder.
So
cd C:\Users\User\AppData\Roaming\npm
Then run
react-native init AppName