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

make lint-js throws error #41771

Closed
MrJithil opened this issue Jan 30, 2022 · 18 comments
Closed

make lint-js throws error #41771

MrJithil opened this issue Jan 30, 2022 · 18 comments
Labels
tools Issues and PRs related to the tools directory.

Comments

@MrJithil
Copy link
Member

Version

v18.0.0-pre

Platform

Linux 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

tools

What steps will reproduce the bug?

run make lint-js and observe the errors in WSL Ubuntu. I have tried the latest source on macOS and faced the same.

/mnt/e/OpenSource/node$ make lint-js
Running JS linter...

Oops! Something went wrong! :(

ESLint: 8.8.0

/mnt/e/OpenSource/node/tools/node_modules/eslint/node_modules/eslint:1
(function (exports, require, module, __filename, __dirname) { ..
                                                              ^

SyntaxError: Unexpected token '.'
    at new Script (node:vm:100:7)
    at NativeCompileCache._moduleCompile (/mnt/e/OpenSource/node/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
    at Module._compile (/mnt/e/OpenSource/node/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (/mnt/e/OpenSource/node/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/mnt/e/OpenSource/node/tools/node_modules/eslint/node_modules/eslint-plugin-jsdoc/dist/rules/checkExamples.js:8:15)
    at Module._compile (/mnt/e/OpenSource/node/tools/node_modules/eslint/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
make: *** [Makefile:1352: lint-js] Error 2

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Linters should run successfully.

What do you see instead?

Errors and linting broken

Additional information

No response

@Trott
Copy link
Member

Trott commented Jan 30, 2022

If you haven't compiled Node.js locally, make lint-js will use the version of node in your path. So I'm guessing you have Node.js 10.x or older installed. Node.js 10.x is unsupported and will result in this error.

To fix the issue, you can either build Node.js locally (no need to install it--just having it built in the your project directory will be enough) or update your system Node.js to 12.x or newer.

@MrJithil
Copy link
Member Author

I'm using the locally built version v18.0.0-pre and the installed version is v16.13.2

image

@Trott
Copy link
Member

Trott commented Jan 30, 2022

@MrJithil OK, that's surprising. What happens if you run tools/node_modules/eslint/bin/eslint.js from the command line?

@Trott
Copy link
Member

Trott commented Jan 30, 2022

@MrJithil OK, that's surprising. What happens if you run tools/node_modules/eslint/bin/eslint.js from the command line?

In particular, since you have the 18.0.0-pre compiled, do all three of these work?

$ tools/node_modules/eslint/bin/eslint.js
$ node tools/node_modules/eslint/bin/eslint.js
$ ./node tools/node_modules/eslint/bin/eslint.js
$ 

@MrJithil
Copy link
Member Author

Except for the first one, the rest of them are executing well.
image

But, it's not a throwing error while manually creating a lint error in a file.

@benjamingr
Copy link
Member

Hmm, that's odd since it takes node from the environment so if node tools/node_modules/eslint/bin/eslint.js passes then tools/node_modules/eslint/bin/eslint.js should too.

It might be a WSL related issue? (though why would it?) there is probably something else at play based on the environment.

@Trott
Copy link
Member

Trott commented Jan 30, 2022

Seems like the problem is happening in call available-node in the Makefile. Let's confirm that.

Does make tools/doc/node_modules fail in a similar way? Or does that succeed?

@VoltrexKeyva VoltrexKeyva added the tools Issues and PRs related to the tools directory. label Jan 30, 2022
@MrJithil
Copy link
Member Author

MrJithil commented Jan 31, 2022

image
Seems return success.

@Trott
Copy link
Member

Trott commented Jan 31, 2022

image Seems return success.

The way make works, that didn't run anything because the target is already built. Do this to cause make to try to run the recipe:

touch tools/doc/package.json && make tools/doc/node_modules

If that fails, at least we have a narrow area to find the cause of the problem. If that succeeds, the search continues....

@MrJithil
Copy link
Member Author

MrJithil commented Feb 1, 2022

touch: setting times of 'tools/doc/package.json': Invalid argument

Got this error

@Trott
Copy link
Member

Trott commented Feb 1, 2022

touch: setting times of 'tools/doc/package.json': Invalid argument

Got this error

OK, instead of using touch, how about remove tools/doc/node_modules and then run make tools/doc/node_modules?

@MrJithil
Copy link
Member Author

MrJithil commented Feb 1, 2022

Sorry. I ran the previous command in the wrong shell. Now, I corrected it and ran touch tools/doc/package.json && make tools/doc/node_modules again.

Waiting for the results.

Seems like its taking time.

@MrJithil
Copy link
Member Author

MrJithil commented Feb 1, 2022

image
Here is the error for touch tools/doc/package.json && make tools/doc/node_modules

Trying now with remove tools/doc/node_modules and then run make tools/doc/node_modules

@MrJithil
Copy link
Member Author

MrJithil commented Feb 1, 2022

And below is the output @Trott
image

@Trott
Copy link
Member

Trott commented Feb 1, 2022

Are you sure you removed tools/doc/node_modules before running make tools/doc/node_modules? Can you confirm that whatever command you use to remove it succeeded? Maybe do a directory listing and confirm that it's not there? There's no way that removing the directory and then running make tools/doc/node_modules should report that the directory, which you just removed, is up to date. So either the directory was not removed, or else something is truly deeply broken with make (or something make depends on) in your setup.

@MrJithil
Copy link
Member Author

MrJithil commented Feb 2, 2022

Hello @Trott, Finally discovered the issue.

wsl instance unable to resolve the npm.org was the underlying issue. I have changed the DNS resolver to 8.8.8.8 and restarted the systemd-networkd service. After restarting the windows, I am able to run make tools/doc/node_modules successfully.

Also, as you suggested tools/doc/node_modules directory is hidden and not showing in the filesystem. I have run the rm -r tools/doc/node_modules to ensure this is completely removed from the disk.

All good now. Thank you again @Trott for your kind support and a lot of effort to fix this case.

@Trott Trott closed this as completed Feb 2, 2022
@Trott
Copy link
Member

Trott commented Feb 2, 2022

Glad you got it worked out!

@Mesteery
Copy link
Contributor

Mesteery commented Feb 17, 2022

I have the same issue on Windows (outside WSL):

PS C:\Users\x\workspace\nodejs\node> node -v
v16.13.0
PS C:\Users\x\workspace\nodejs\node> node tools/node_modules/eslint/bin/eslint.js .eslintrc.js benchmark doc lib test tools        

Oops! Something went wrong! :(

ESLint: 8.9.0

C:\Users\x\workspace\nodejs\node\tools\node_modules\eslint\node_modules\eslint:1
(function (exports, require, module, __filename, __dirname) { ..
                                                              ^

SyntaxError: Unexpected token '.'
    at new Script (node:vm:100:7)
    at NativeCompileCache._moduleCompile (C:\Users\x\workspace\nodejs\node\tools\node_modules\eslint\node_modules\v8-compile-cache\v8-compile-cache.js:240:18)
    at Module._compile (C:\Users\x\workspace\nodejs\node\tools\node_modules\eslint\node_modules\v8-compile-cache\v8-compile-cache.js:184:36)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (C:\Users\x\workspace\nodejs\node\tools\node_modules\eslint\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\x\workspace\nodejs\node\tools\node_modules\eslint\node_modules\eslint-plugin-jsdoc\dist\rules\checkExamples.js:8:15)
    at Module._compile (C:\Users\x\workspace\nodejs\node\tools\node_modules\eslint\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Issues and PRs related to the tools directory.
Projects
None yet
Development

No branches or pull requests

5 participants