Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows 使用 nodejs v18.1.0 导入 starcoin js sdk 后出现 MODULE_NOT_FOUND #50

Closed
WGB5445 opened this issue May 17, 2022 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@WGB5445
Copy link
Contributor

WGB5445 commented May 17, 2022

用 npm install @starcoin/starcoin 后,编写代码

const {
    utils,
    encoding,
    starcoin_types,
} = require('@starcoin/starcoin');
console.log(utils)

使用 node .\test.js 出现报错

node:internal/modules/cjs/loader:942
  throw err;
  ^

Error: Cannot find module 'safe-buffer'
Require stack:
- C:\Users\WGB\Desktop\code\node_modules\@starcoin\starcoin\dist\starcoin.js
- C:\Users\WGB\Desktop\code\test.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Module._load (node:internal/modules/cjs/loader:780:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\WGB\Desktop\code\node_modules\@starcoin\starcoin\dist\starcoin.js:2962:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\WGB\\Desktop\\code\\node_modules\\@starcoin\\starcoin\\dist\\starcoin.js',
    'C:\\Users\\WGB\\Desktop\\code\\test.js'
  ]
}

Node.js v18.1.0
@WGB5445 WGB5445 changed the title [MODULE_NOT_FOUND] 使用 nodejs v18.1.0 导入 starcoin js sdk 后出现 MODULE_NOT_FOUND windows 使用 nodejs v18.1.0 导入 starcoin js sdk 后出现 MODULE_NOT_FOUND May 17, 2022
@jolestar jolestar added the help wanted Extra attention is needed label May 18, 2022
@uvd
Copy link
Contributor

uvd commented May 19, 2022

可以提供一份完整的代码仓库me @WGB5445

@WGB5445
Copy link
Contributor Author

WGB5445 commented May 19, 2022

是一个空的 nodejs 工程

test.js

const {
    utils,
    encoding,
    starcoin_types,
} = require('@starcoin/starcoin');
console.log(utils)

执行命令 node .\test.js

node:internal/modules/cjs/loader:942
  throw err;
  ^

Error: Cannot find module 'safe-buffer'
Require stack:
- C:\Users\WGB\Desktop\code\node_modules\@starcoin\starcoin\dist\starcoin.js
- C:\Users\WGB\Desktop\code\test.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Module._load (node:internal/modules/cjs/loader:780:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\WGB\Desktop\code\node_modules\@starcoin\starcoin\dist\starcoin.js:2962:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\WGB\\Desktop\\code\\node_modules\\@starcoin\\starcoin\\dist\\starcoin.js',
    'C:\\Users\\WGB\\Desktop\\code\\test.js'
  ]
}

Node.js v18.1.0

不确定是不是 nodejs 太新的缘故

@WGB5445
Copy link
Contributor Author

WGB5445 commented May 19, 2022

重新安装环境以后这个问题消失了,我考虑可能是由于在 yarn 或者 npm 时网络中断导致的 'safe-buffer' 并未下载

@WGB5445 WGB5445 closed this as completed May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants