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

How to run index.js #8

Open
saclim opened this issue Mar 5, 2021 · 0 comments
Open

How to run index.js #8

saclim opened this issue Mar 5, 2021 · 0 comments

Comments

@saclim
Copy link

saclim commented Mar 5, 2021

Hi. I have tried the following ways to run the index.js file in windows powershell (run as administrative), but I got error. Can you please advise what is going wrong and how I can solve the issue?

  1. W2th node index.js, I got the error message:
    (node:15284) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
    (Use node --trace-warnings ... to show where the warning was created)
    C:\Users\sali8720\jsonld-vis-master\jsonld-vis-master\example\index.js:1
    import d3 from 'd3';
    ^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47

  1. I then go to package.json, add "type":"module", and save. Then I run with the command node index.js again. This time, I got the following error.

internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'd3' imported from C:\Users\sali8720\jsonld-vis-master\jsonld-vis-master\example\index.js
←[90m at packageResolve (internal/modules/esm/resolve.js:655:9)←[39m
←[90m at moduleResolve (internal/modules/esm/resolve.js:696:18)←[39m
←[90m at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)←[39m
←[90m at Loader.resolve (internal/modules/esm/loader.js:86:40)←[39m
←[90m at Loader.getModuleJob (internal/modules/esm/loader.js:230:28)←[39m
←[90m at ModuleWrap. (internal/modules/esm/module_job.js:56:40)←[39m
←[90m at link (internal/modules/esm/module_job.js:55:36)←[39m {
code: ←[32m'ERR_MODULE_NOT_FOUND'←[39m

  1. By using the original package.json, I changed the extension of index.js to index.mjs, and run node index.mjs.

internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'd3' imported from C:\Users\sali8720\jsonld-vis-master\jsonld-vis-master\example\index.mjs
←[90m at packageResolve (internal/modules/esm/resolve.js:655:9)←[39m
←[90m at moduleResolve (internal/modules/esm/resolve.js:696:18)←[39m
←[90m at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)←[39m
←[90m at Loader.resolve (internal/modules/esm/loader.js:86:40)←[39m
←[90m at Loader.getModuleJob (internal/modules/esm/loader.js:230:28)←[39m
←[90m at ModuleWrap. (internal/modules/esm/module_job.js:56:40)←[39m
←[90m at link (internal/modules/esm/module_job.js:55:36)←[39m {
code: ←[32m'ERR_MODULE_NOT_FOUND'←[39m
}

modify_package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant