Skip to content

atian25/node-bug-report

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bug Report

vscode-js-debug will inject an env NODE_OPTIONS.

Which will cause a bug of Node.js 10.x to crash when fork child process.

Code

const cp = require('child_process');
const path = require('path');

console.log(process.env.NODE_OPTIONS);
console.log(process.execPath);
console.log(process.version);

const filePath = path.join(__dirname, 'lib space/test.js');
console.log(filePath);

const child = cp.spawn(process.execPath,
  [ '-e', 'console.log(process.env.NODE_OPTIONS)' ],
  {
    stdio: 'inherit',
    env: {
      NODE_OPTIONS: `--require "${filePath}"`
    }
});

child.on('exit', function (code, signal) {
  console.log(code, signal)
});

Bad

10.x is crash.

Step:

{
  "dependencies": {
    "node": "^10.22.1"
  }
}

Run:

$ npm i
$ npm start

Error: Cannot find module '"/path/to/test-tnpm/lib'

Good

Change node to 12.x, it works.

Step:

{
  "dependencies": {
    "node": "^12.15.0"
  }
}

Run:

$ rm -rf node_modules
$ npm i
$ npm start

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published