安装了一个包含源文件的模块,但仍然出现引用错误
Installed a module containing a source file, but still getting a reference error
我刚刚安装了一个包 -- https://github.com/ryohey/node-stratum-client 使用
npm install node-stratum-client
虽然我可以看到这个文件已安装
./node_modules/node-stratum-client/src/StratumClient.ts
当我尝试 运行 包含这些行的节点脚本时
require("node-stratum-client")
const client = new StratumClient()
我收到一个错误
/Users/satishp/Documents/workspace/run.js:3
const client = new StratumClient()
^
ReferenceError: StratumClient is not defined
at Object.<anonymous> (/Users/satishp/Documents/workspace/run.js:3:16)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:193:16)
at bootstrap_node.js:617:3
我正在使用 npm v 5.6.0。我需要安装什么文件才能让我的节点脚本识别我安装的模块?
您需要将所需的模块存储在变量中:
const StratumClient = require('node-stratum-client')
const client = new StratumClient()
我刚刚安装了一个包 -- https://github.com/ryohey/node-stratum-client 使用
npm install node-stratum-client
虽然我可以看到这个文件已安装
./node_modules/node-stratum-client/src/StratumClient.ts
当我尝试 运行 包含这些行的节点脚本时
require("node-stratum-client")
const client = new StratumClient()
我收到一个错误
/Users/satishp/Documents/workspace/run.js:3
const client = new StratumClient()
^
ReferenceError: StratumClient is not defined
at Object.<anonymous> (/Users/satishp/Documents/workspace/run.js:3:16)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:193:16)
at bootstrap_node.js:617:3
我正在使用 npm v 5.6.0。我需要安装什么文件才能让我的节点脚本识别我安装的模块?
您需要将所需的模块存储在变量中:
const StratumClient = require('node-stratum-client')
const client = new StratumClient()