0

I have installed JDK and set up the home variable:

C:\Workspace\ProjectFolder>echo %JAVA_HOME%
C:\Program Files\Java\jdk-11.0.6

Then i have done:

npm install maven -g

Info about the NODE:

C:\Workspace\ProjectFolder>node --version
v10.16.3

Okay, lets see the info about MAVEN:

C:\Workspace\ProjectFolder>mvn --version
fs.js:136
    throw new ERR_INVALID_CALLBACK();
    ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at makeCallback (fs.js:136:11)
    at Object.mkdir (fs.js:726:14)
    at Object.target.init (C:\Users\MyUSER\AppData\Roaming\npm\node_modules\mvn\target.js:25:10)
    at Object.<anonymous> (C:\Users\MyUSER\AppData\Roaming\npm\node_modules\mvn\target.js:39:8)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)

What is wrong?

Developer
  • 4,158
  • 5
  • 34
  • 66
  • Looks like a permission problem. There is a call `fs.accessSync(target.home, fs.F_OK)` which fails. Could you check if the user which runs node has access to the `/.maven` directory? – LEQADA Mar 17 '20 at 10:41

1 Answers1

3

(The npm package you've installed is mvn, not maven.)

Because the .maven directory doesn't existing, it's attempting to create it with this line:

fs.mkdir(target.home);

However, it's calling mkdir without a callback. Since Node 10, that's an error. You'll need to use an earlier Node, or fix the code to pass a callback. See how to fix this error TypeError [ERR_INVALID_CALLBACK]: Callback must be a function for an equivalent change.

If you're trying to use Maven, simply install it directly, rather than using a Node wrapper.

Joe
  • 29,416
  • 12
  • 68
  • 88