error when install loom-truffle-provider: verbose stack Error: The git reference could not be found

created at 05-31-2022 views: 10

environment

  • win10
  • node v16.13.2

problem

After learning the tutorial of CryptoZombies, I used npm to install truffle: npm i truffle -g, but I got an error after installing it for a long time:

...
600 verbose stack Error: The git reference could not be found
600 verbose stack     at makeError (C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\git\lib\make-error.js:26:13)
600 verbose stack     at C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\git\lib\spawn.js:37:26
600 verbose stack     at processTicksAndRejections (node:internal/process/task_queues:96:5)
600 verbose stack     at async Object.withTempDir (C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\fs\lib\with-temp-dir.js:23:14)
600 verbose stack     at async Arborist.[nodeFromEdge] (C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:1101:19)
600 verbose stack     at async Arborist.[buildDepStep] (C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:970:11)
600 verbose stack     at async Arborist.buildIdealTree (C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:216:7)
600 verbose stack     at async Promise.all (index 1)
600 verbose stack     at async Arborist.reify (C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:153:5)
600 verbose stack     at async Install.exec (C:\Users\fygame\AppData\Roaming\npm\node_modules\npm\lib\commands\install.js:159:5)
601 verbose cwd C:\Users\fygame\AppData\Local\npm-cache\_cacache\tmp\git-cloneKsTTeb
602 verbose Windows_NT 10.0.19041
603 verbose node v16.13.2
604 verbose npm  v8.6.0
605 error code 1
606 error The git reference could not be found
607 error command git --no-replace-objects checkout 4.0
608 error error: pathspec '4.0' did not match any file(s) known to git
609 verbose exit 1
610 timing npm Completed in 9389ms
611 verbose unfinished npm timer reify 1653969341713
612 verbose unfinished npm timer reify:loadTrees 1653969341729
613 verbose code 1
614 error A complete log of this run can be found in:
614 error     C:\Users\fygame\AppData\Local\npm-cache\_logs\2022-05-31T03_55_41_489Z-debug-0.log

problem Tracking

The key error message is

608 error error: pathspec '4.0' did not match any file(s) known to git

For context, there is probably a gulp@4.0 in the dependency package, but this version has been officially removed from git.

There is the same question on stackoverflow

One of the answers mentioned that using node11 would be fine. Then let's try. I want to use node11 only when installing truffle, usually node16, so I introduce the next question, how to manage multiple versions of nodejs?

Use nvs to manage different versions of NodeJs It's very simple, it's clearly told to you on npm's github~

  • nvm
  • nvs
  • nave
  • n
  • volta
  • noenv
  • asdf-nodejs
  • nvm-windows
  • fnm

I have used nvm before, but it does not have an official windows installation package. It is a little troublesome to install it through a script. There is nvm-windows maintained by a third party, but I tried it, and an error was reported when installing node11.15.0, because it failed to download npm. Mmm... let's change it, look at this nvs, the official introduction says that it is inspired by nvm, and it is cross-platform, it feels more advanced than nvm, and there is an official windows installation package. After installation, enter the command nvs to select the nodejs version to be installed, which is much more convenient than nvm~

Note: nvs cannot change the installation directory, it will be installed under %LOCALAPPDATA%/nvs

C:\Users\fygame>nvs
Downloading [###########################################################################################] 100%
Extracting  [###########################################################################################] 100%
PATH += %LOCALAPPDATA%\nvs\node\11.15.0\x64

Check node version

C:\Users\fygame>node -v
v11.15.0

View installed node

C:\Users\fygame>nvs list
>node/11.15.0/x64

View the installation directory of a version of node

C:\Users\fygame>nvs which 11.15.0
C:\Users\fygame\AppData\Local\nvs\node\11.15.0\x64\node.exe

Woohoo, I have installed it on the C drive, I don't have enough space on the C drive, then change the npm global module directory to the E drive :)

C:\Users\fygame>npm config set prefix E:\npm\prefix

C:\Users\fygame>npm config get prefix
E:\npm\prefix

Try installing truffle

C:\Users\fygame>npm i truffle -g
npm WARN deprecated uuid@2.0.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
...
> truffle@5.5.16 postinstall E:\npm\prefix\node_modules\truffle
> node ./scripts/postinstall.js

Error: Error while attempting to download and cache solc 0.5.16: Command failed: node ./build/cli.bundled.js obtain --solc=0.5.16
    at postinstallObtain (E:\npm\prefix\node_modules\truffle\scripts\postinstall.js:13:11)
    at Object.<anonymous> (E:\npm\prefix\node_modules\truffle\scripts\postinstall.js:20:3)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @zondax/filecoin-signing-tools@github:trufflesuite/filecoin-signing-tools-js (node_modules\truffle\node_modules\@trufflesuite\filecoin.js\node_modules\@zondax\filecoin-signing-tools):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: Error while executing:
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: undefined ls-remote -h -t ssh://git@github.com/trufflesuite/filecoin-signing-tools-js.git
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY:
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY:
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: spawn git ENOENT
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\truffle\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN ajv-formats@2.1.1 requires a peer of ajv@^8.0.0 but none is installed. You must install peer dependencies yourself.

+ truffle@5.5.16
added 1141 packages from 768 contributors in 930.877s

The previous error is gone, but this new error (it seems to be an error when executing a script after installation) does not seem to affect the use of truffle.

try to use truffle:

G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle>truffle
'truffle' is not an internal or external command, nor a runnable program
or batch file.

G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle>npx truffle
(node:6492) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added. Use emitter.setMaxListeners() to increase limit
Error: Error while attempting to download and cache solc 0.5.16: Command failed: node ./build/cli.bundled.js obtain --solc=0.5.16
    at postinstallObtain (C:\Users\admin\AppData\Roaming\npm-cache\_npx\8332\node_modules\truffle\scripts\postinstall.js:13:11)
    at Object.<anonymous> (C:\Users\admin\AppData\Roaming\npm-cache\_npx\8332\node_modules\truffle\scripts\postinstall.js:20:3)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11
Error: Node version not supported. You are currently using version 11.15.0 of Node. Truffle requires Node v12.0.0 or higher.

This...truffle requires node 12.0.0 .... Then install node v12.22.12~ The installation process is the same as above.

Make node12 the default

G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle>nvs link 12.22.12
%LOCALAPPDATA%\nvs\default -> %LOCALAPPDATA%\nvs\node\12.22.12\x64

Reinstall truffle, this time the above two errors are gone!

G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle>npm i truffle -S
npm WARN deprecated uuid@2.0.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated mkdirp-promise@5.0.1: This package is broken and no longer maintained. 'mkdirp' itself supports promises now, please switch to that.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated cids@0.7.5: This module has been superseded by the multiformats module
npm WARN deprecated multicodec@0.5.7: This module has been superseded by the multiformats module
npm WARN deprecated multicodec@1.0.4: This module has been superseded by the multiformats module
npm WARN deprecated multibase@0.6.1: This module has been superseded by the multiformats module
npm WARN deprecated multibase@0.7.0: This module has been superseded by the multiformats module
npm WARN deprecated uuid@3.2.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated node-pre-gyp@0.11.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm WARN deprecated cids@1.1.9: This module has been superseded by the multiformats module
npm WARN deprecated multibase@3.1.2: This module has been superseded by the multiformats module
npm WARN deprecated multibase@4.0.6: This module has been superseded by the multiformats module
npm WARN deprecated multicodec@3.2.1: This module has been superseded by the multiformats module
npm WARN deprecated ipld-dag-pb@0.20.0: This module has been superseded by @ipld/dag-pb and multiformats
npm WARN deprecated ipld-dag-cbor@0.17.1: This module has been superseded by @ipld/dag-cbor and multiformats
npm WARN deprecated multicodec@2.1.3: This module has been superseded by the multiformats module
npm WARN deprecated ipld-raw@6.0.0: This module has been superseded by the multiformats module
npm WARN deprecated @nodefactory/filsnap-adapter@0.2.2: Package is deprecated in favour of @chainsafe/filsnap-adapter

> @trufflesuite/bigint-buffer@1.1.9 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\ganache\node_modules\@trufflesuite\bigint-buffer
> node-gyp-build || echo "Couldn't build bindings. Non-native version used."


> bufferutil@4.0.5 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\ganache\node_modules\bufferutil
> node-gyp-build


> keccak@3.0.1 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\ganache\node_modules\keccak
> node-gyp-build || exit 0


> leveldown@6.1.0 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\ganache\node_modules\leveldown
> node-gyp-build


> secp256k1@4.0.2 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\ganache\node_modules\secp256k1
> node-gyp-build || exit 0


> utf-8-validate@5.0.7 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\ganache\node_modules\utf-8-validate
> node-gyp-build


> iso-constants@0.1.2 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\iso-constants
> node build.js > index.browser.js


> bufferutil@4.0.6 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\bufferutil
> node-gyp-build


> secp256k1@4.0.3 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\secp256k1
> node-gyp-build || exit 0


> ursa-optional@0.10.2 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\ursa-optional
> node rebuild.js

ursaNative bindings compilation fail. This is not an issue. Modules that depend on it will use fallbacks.

> utf-8-validate@5.0.9 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\utf-8-validate
> node-gyp-build


> keccak@3.0.2 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\keccak
> node-gyp-build || exit 0


> leveldown@5.6.0 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\leveldown
> node-gyp-build


> sqlite3@4.2.0 install G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
[sqlite3] Success: "G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\sqlite3\lib\binding\node-v72-win32-x64\node_sqlite3.node" is installed via remote

> @apollo/protobufjs@1.2.2 postinstall G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\@apollo\protobufjs
> node scripts/postinstall


> protobufjs@6.11.3 postinstall G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\protobufjs
> node scripts/postinstall


> es5-ext@0.10.61 postinstall G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\es5-ext
>  node -e "try{require('./_postinstall')}catch(e){}" || exit 0


> web3-shh@1.5.3 postinstall G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\web3-shh
> echo "WARNING: the web3-shh api will be deprecated in the next version"

"WARNING: the web3-shh api will be deprecated in the next version"

> web3-bzz@1.5.3 postinstall G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\web3-bzz
> echo "WARNING: the web3-bzz api will be deprecated in the next version"

"WARNING: the web3-bzz api will be deprecated in the next version"

> web3@1.5.3 postinstall G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\web3
> echo "WARNING: the web3-shh and web3-bzz api will be deprecated in the next version"

"WARNING: the web3-shh and web3-bzz api will be deprecated in the next version"

> truffle@5.5.16 postinstall G:\tgit\eth\cryptozombiestrial\oracle\EthPriceOracle\node_modules\truffle
> node ./scripts/postinstall.js

- Fetching solc version list from solc-bin. Attempt #1
- Fetching solc version list from solc-bin. Attempt #1
- Fetching solc version list from solc-bin. Attempt #1
- Downloading compiler. Attempt #1.
- Fetching solc version list from solc-bin. Attempt #1
- Downloading compiler. Attempt #1.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for peer-id@0.14.8: wanted: {"node":">=14.0.0"} (current: {"node":"12.22.12","npm":"6.14.16"})
npm WARN notsup Not compatible with your version of node/npm: peer-id@0.14.8
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @zondax/filecoin-signing-tools@github:trufflesuite/filecoin-signing-tools-js (node_modules\@trufflesuite\filecoin.js\node_modules\@zondax\filecoin-signing-tools):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error while executing:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: D:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://git@github.com/trufflesuite/filecoin-signing-tools-js.git
npm WARN optional SKIPPING OPTIONAL DEPENDENCY:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ssh: connect to host github.com port 22: Connection refused
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fatal: Could not read from remote repository.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Please make sure you have the correct access rights
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: and the repository exists.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: exited with error code: 128
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN ajv-formats@2.1.1 requires a peer of ajv@^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN EthPriceOracle@1.0.0 No description
npm WARN EthPriceOracle@1.0.0 No repository field.

+ truffle@5.5.16
added 1141 packages from 768 contributors and audited 1144 packages in 242.581s

100 packages are looking for funding
  run `npm fund` for details

found 16 vulnerabilities (6 low, 4 moderate, 6 high)
  run `npm audit fix` to fix them, or `npm audit` for details

conclusion

To install truffle, you need node v12.0.0 or above (I use v12.22.12), node v16.13.2 may not support it.

created at:05-31-2022
edited at: 05-31-2022: