node-voo icon indicating copy to clipboard operation
node-voo copied to clipboard

Windows: set NODE_OPTIONS fails to run npm afterwards

Open creage opened this issue 6 years ago • 3 comments

  1. Installed node-voo globally
npm i node-voo -g
  1. Set NODE_OPTIONS as described in documentation
set NODE_OPTIONS=-r node-voo
node <real-entry> <arguments>

And now every npm run fails with error

internal/modules/cjs/loader.js:611
    throw err;
    ^

Error: Cannot find module 'node-voo'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
    at Function.Module._load (internal/modules/cjs/loader.js:535:25)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:865:12)
    at prepareUserCodeExecution (internal/bootstrap/node.js:483:5)
    at startMainThreadExecution (internal/bootstrap/node.js:438:3)
internal/modules/cjs/loader.js:611
    throw err;
    ^

Error: Cannot find module 'node-voo'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
    at Function.Module._load (internal/modules/cjs/loader.js:535:25)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at Module._preloadModules (internal/modules/cjs/loader.js:865:12)
    at prepareUserCodeExecution (internal/bootstrap/node.js:483:5)
    at startMainThreadExecution (internal/bootstrap/node.js:438:3)

Windows 10 Node 11.9.0

creage avatar Jan 31 '19 08:01 creage

@creage is this thrown from a child process? is node-voo requirable from the location of that file?

hulkish avatar Jan 31 '19 16:01 hulkish

@hulkish I've installed node-voo globally, so yes - it is accessible. And I can run node <script> with no problems. It is only npm fails.

creage avatar Jan 31 '19 16:01 creage

@creage installing it globally does not guarantee it will work. It must be in one of the node_modules dirs which exist relative to where you are doing the require.

Since you're using NODE_OPTIONS="-r node-voo", it still tries to require it locally - not globally. So, you should do one of:

  • install it locally to the project (recommended)
  • provide absolute path to -r globally installed of location node-voo

hulkish avatar Feb 01 '19 16:02 hulkish