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

Node throws error on 'hackmyresume new' #238

Open
leoossa opened this issue Jul 21, 2021 · 2 comments
Open

Node throws error on 'hackmyresume new' #238

leoossa opened this issue Jul 21, 2021 · 2 comments

Comments

@leoossa
Copy link

leoossa commented Jul 21, 2021

At first hackmyresume new threw:

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

Error: Cannot find module 'escape-string-regexp'
Require stack:
- /usr/lib/node_modules/hackmyresume/node_modules/chalk/index.js
- /usr/lib/node_modules/hackmyresume/dist/utils/md2chalk.js
- /usr/lib/node_modules/hackmyresume/dist/cli/error.js
- /usr/lib/node_modules/hackmyresume/dist/cli/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
    at Function.Module._load (node:internal/modules/cjs/loader:774:27)
    at Module.require (node:internal/modules/cjs/loader:1013:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/usr/lib/node_modules/hackmyresume/node_modules/chalk/index.js:2:28)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Module.require (node:internal/modules/cjs/loader:1013:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/lib/node_modules/hackmyresume/node_modules/chalk/index.js',
    '/usr/lib/node_modules/hackmyresume/dist/utils/md2chalk.js',
    '/usr/lib/node_modules/hackmyresume/dist/cli/error.js',
    '/usr/lib/node_modules/hackmyresume/dist/cli/index.js'
  ]
}

It was installed with sudo npm install hackmyresume -g.

I tried solutions:

  • npm install --save escape-string-regexp; delete your item/node_module and then re-execute npm install
  • npm install --save-dev escape-string-regexp
  • npm i -g npm; delete the node_modules folder and run npm cache clean and then npm install

suggested here and here but none of them helped.

Eventually I installed package globally with sudo npm install --save-dev escape-string-regexp -g that helped with finding the package and resolving previous issue, but effectively coming with the new one:

node:internal/modules/cjs/loader:1126
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/lib/node_modules/escape-string-regexp/index.js
require() of ES modules is not supported.
require() of /usr/lib/node_modules/escape-string-regexp/index.js from /usr/lib/node_modules/hackmyresume/node_modules/chalk/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /usr/lib/node_modules/escape-string-regexp/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/lib/node_modules/escape-string-regexp/package.json.

    at new NodeError (node:internal/errors:363:5)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1126:13)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Module.require (node:internal/modules/cjs/loader:1013:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/usr/lib/node_modules/hackmyresume/node_modules/chalk/index.js:2:28)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32) {
  code: 'ERR_REQUIRE_ESM'
}

I'm not proud to admit that resigned of further investigation because I installed fork of hackmyresume that is FluentCV and it works out-of-the-box.
I'm opening this issue because it may be useful for somebody one day and that info may help if any comes up with similar problem.

@michaeltlombardi
Copy link

I was just able to reproduce this issue on my machine getting both sets of error messages (the latter after installing escape-string-regexp globally).

  • Node: v16.6.1
  • NPM: 7.20.3
  • hackmyresume: 1.9.0-beta (installed via npm install -g hackmyresume)

Further, I noticed the issue was across any command, including hackmyresume -v

Downgrading to 1.8.0 worked without issues.

@melissamcewen
Copy link

melissamcewen commented Nov 1, 2024

Another way around it is cloning the main branch and installing it locally

git clone [email protected]:hacksalot/HackMyResume.git
npm install HackMyResume

Perhaps whatever caused it was fixed since the last release

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

3 participants