求npm 引入 web3的方法
直接npm install web3 就是这个结果:
2021-03-14 17:53:29-error: 无法加载模块 file:///crypto :Error: 在加载模块文件 /crypto 时发生错误:Error: ENOENT: no such file or directory, open ‘/crypto’.
2021-03-14 17:53:29-error: 无法加载模块 file:///buffer :Error: 在加载模块文件 /buffer 时发生错误:Error: ENOENT: no such file or directory, open ‘/buffer’.
2021-03-14 17:53:29-error: 无法加载模块 file:///os :Error: 在加载模块文件 /os 时发生错误:Error: ENOENT: no such file or directory, open ‘/os’.
2021-03-14 17:53:29-error: 无法加载模块 file:///path :Error: 在加载模块文件 /path 时发生错误:Error: ENOENT: no such file or directory, open ‘/path’.
2021-03-14 17:53:29-error: 无法加载模块 file:///child_process :Error: 在加载模块文件 /child_process 时发生错误:Error: ENOENT: no such file or directory, open ‘/child_process’.
2021-03-14 17:53:27-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/web3/package.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “web3”,
| ^
3 | “version”: “1.3.4”,
4 | “description”: “Ethereum JavaScript API”,
5 | “repository”: “https://github.com/ethereum/web3.js”,.
2021-03-14 17:53:30-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/swarm-js/archives/archives.json :SyntaxError: unknown: Unexpected token, expected “;” (2:17)
1 | {
2 | “windows-amd64”: {
| ^
3 | “archive”: “swarm-windows-amd64-1.6.7.exe”,
4 | “binaryMD5”: “c2d827dc4553d9b91a7d6c1d5a6140fd”,
5 | “archiveMD5”: “059196d21548060a18a12e17cc0ee59a”.
2021-03-14 17:53:30-error: 无法加载模块 file:///assert :Error: 在加载模块文件 /assert 时发生错误:Error: ENOENT: no such file or directory, open ‘/assert’.
2021-03-14 17:53:30-error: 无法加载模块 file:///http :Error: 在加载模块文件 /http 时发生错误:Error: ENOENT: no such file or directory, open ‘/http’.
2021-03-14 17:53:31-error: 无法加载模块 file:///https :Error: 在加载模块文件 /https 时发生错误:Error: ENOENT: no such file or directory, open ‘/https’.
2021-03-12 21:05:41-warn: [Scene] No need to specify the “type” of “MyBotton.hoverLabelColor” because cc.Color is a child class of ValueType. Just set the default value to ‘new cc.Color()’ and it will be handled properly. MyBotton hoverLabelColor cc.Color
2021-03-14 17:53:32-error: 无法加载模块 file:///stream :Error: 在加载模块文件 /stream 时发生错误:Error: ENOENT: no such file or directory, open ‘/stream’.
2021-03-14 17:53:32-error: 无法加载模块 file:///url :Error: 在加载模块文件 /url 时发生错误:Error: ENOENT: no such file or directory, open ‘/url’.
2021-03-14 17:53:29-error: 无法加载模块 file:///util :Error: 在加载模块文件 /util 时发生错误:Error: ENOENT: no such file or directory, open ‘/util’.
2021-03-14 17:53:32-error: 无法加载模块 file:///querystring :Error: 在加载模块文件 /querystring 时发生错误:Error: ENOENT: no such file or directory, open ‘/querystring’.
2021-03-14 17:53:32-error: 无法加载模块 file:///events :Error: 在加载模块文件 /events 时发生错误:Error: ENOENT: no such file or directory, open ‘/events’.
2021-03-14 17:43:16-warn: [Scene] No need to specify the “type” of “MyBotton.hoverLabelColor” because cc.Color is a child class of ValueType. Just set the default value to ‘new cc.Color()’ and it will be handled properly. MyBotton hoverLabelColor cc.Color
2021-03-14 17:53:34-error: 无法从 file:///Users/necklace/work/Legend/client/Legend/node_modules/swarm-js/node_modules/got/index.js 解析出模块 ./package,已将其视为外部模块。
这是因为:Error: 以 file:///Users/necklace/work/Legend/client/Legend/node_modules/swarm-js/node_modules/got/index.js 为起点找不到模块 “./package”
2021-03-14 17:53:34-error: 无法加载模块 file:///fs :Error: 在加载模块文件 /fs 时发生错误:Error: ENOENT: no such file or directory, open ‘/fs’.
2021-03-14 17:53:34-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/mime-db/db.json :SyntaxError: unknown: Unexpected token, expected “;” (2:40)
1 | {
2 | “application/1d-interleaved-parityfec”: {
| ^
3 | “source”: “iana”
4 | },
5 | “application/3gpdash-qoe-report+xml”: {.
2021-03-14 17:53:35-error: 无法加载模块 file:///constants :Error: 在加载模块文件 /constants 时发生错误:Error: ENOENT: no such file or directory, open ‘/constants’.
2021-03-14 17:53:36-error: 无法加载模块 file:///zlib :Error: 在加载模块文件 /zlib 时发生错误:Error: ENOENT: no such file or directory, open ‘/zlib’.
2021-03-14 17:53:36-error: 无法加载模块 file:///async_hooks :Error: 在加载模块文件 /async_hooks 时发生错误:Error: ENOENT: no such file or directory, open ‘/async_hooks’.
2021-03-14 17:53:34-error: 无法从 file:///Users/necklace/work/Legend/client/Legend/node_modules/swarm-js/node_modules/got/index.js 解析出模块 electron,已将其视为外部模块。
这是因为:Error: 以 file:///Users/necklace/work/Legend/client/Legend/node_modules/swarm-js/node_modules/got/index.js 为起点找不到模块 “electron”
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/chains/kovan.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “kovan”,
| ^
3 | “chainId”: 42,
4 | “networkId”: 42,
5 | “comment”: “Parity PoA test network”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/chains/mainnet.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “mainnet”,
| ^
3 | “chainId”: 1,
4 | “networkId”: 1,
5 | “comment”: “The Ethereum main chain”,.
2021-03-14 17:53:34-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/elliptic/package.json :SyntaxError: unknown: Unexpected token, expected “;” (2:8)
1 | {
2 | “name”: “elliptic”,
| ^
3 | “version”: “6.5.4”,
4 | “description”: “EC cryptography”,
5 | “main”: “lib/elliptic.js”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/chains/rinkeby.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “rinkeby”,
| ^
3 | “chainId”: 4,
4 | “networkId”: 4,
5 | “comment”: “PoA test network”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/homestead.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “homestead”,
| ^
3 | “comment”: “Homestead hardfork with protocol and network changes”,
4 | “eip”: {
5 | “url”: “https://eips.ethereum.org/EIPS/eip-606”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/chainstart.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “chainstart”,
| ^
3 | “comment”: “Start of the Ethereum main chain”,
4 | “eip”: {
5 | “url”: “”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/chains/goerli.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “goerli”,
| ^
3 | “chainId”: 5,
4 | “networkId”: 5,
5 | “comment”: “Cross-client PoA test network”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/tangerineWhistle.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “tangerineWhistle”,
| ^
3 | “comment”: “Hardfork with gas cost changes for IO-heavy operations”,
4 | “eip”: {
5 | “url”: “https://eips.ethereum.org/EIPS/eip-608”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/spuriousDragon.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “spuriousDragon”,
| ^
3 | “comment”: “HF with EIPs for simple replay attack protection, EXP cost increase, state trie clearing, contract code size limit”,
4 | “eip”: {
5 | “url”: “https://eips.ethereum.org/EIPS/eip-607”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/constantinople.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “constantinople”,
| ^
3 | “comment”: “Postponed hardfork including EIP-1283 (SSTORE gas metering changes)”,
4 | “eip”: {
5 | “url”: “https://eips.ethereum.org/EIPS/eip-1013”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/istanbul.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “istanbul”,
| ^
3 | “comment”: “HF targeted for December 2019 following the Constantinople/Petersburg HF”,
4 | “eip”: {
5 | “url”: “https://eips.ethereum.org/EIPS/eip-1679”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/byzantium.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)
1 | {
2 | “name”: “byzantium”,
| ^
3 | “comment”: “Hardfork with new precompiles, instructions and other protocol changes”,
4 | “eip”: {
5 | “url”: “https://eips.ethereum.org/EIPS/eip-609”,.
2021-03-14 17:53:36-error: 无法加载模块 file:///Users/necklace/work/Legend/client/Legend/node_modules/ethereumjs-common/dist/hardforks/petersburg.json :SyntaxError: unknown: Unexpected token, expected “;” (2:10)