Search code examples
node.jsnpmfedoranvmn

internal/modules/cjs/loader.js:905 -> throw err;


  • Node.js Version: v14.17.3
  • OS: Fedora 34 (Workstation Edition) x86_64
  • Scope (install, code, runtime, meta, other?): node init

Just tried to initialize node at local directory

❯ node init
internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module '/home/searge/Dev/Learn/GoIT/Webpack/init'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []

❯ nvm list
->     v14.17.3
default -> lts/* (-> v14.17.3)

❯ npm -v
7.19.1

First, I have installed n version manager with same problem, so I've installed nvm, but error the same.


Solution

  • I am sure there is no such command node init, you can't init node as it is already installed on your system. You might need to use npm init or npm i to initialise the package.json;

    npm init <initializer> can be used to set up a new or existing npm package.

    initializer in this case is an npm package named create-<initializer>, which will be installed by npm-exec, and then have its main bin executed -- presumably creating or updating package.json and running any other initialization-related operations

    For more details check npm docs.