最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - the error is Cannot read properties of undefined (reading 'random') while trying to get random name

programmeradmin0浏览0评论
import superheroes from 'superheroes';
console.log(superheroes.default.random());

for this code I got this error

(node:1512) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time

(Use `node --trace-warnings ...` to show where the warning was created)
file:///C:/Users/nikhi/Downloads/2.3+NPM%20(1)/2.3%20NPM/index.js:7
console.log(superheroes.default.random());
                                ^

TypeError: Cannot read properties of undefined (reading 'random')
    at file:///C:/Users/nikhi/Downloads/2.3+NPM%20(1)/2.3%20NPM/index.js:7:33
    at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:482:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) how to solve this 

In my tutorials they have taught me this

import superheroes from 'superheroes';
console.log(superheroes.default.random());

I expect you to give correct code to get output

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论