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

The static import statement shows "Resolve error: Missing binary" #1175

Closed
midorizemi opened this issue Feb 4, 2021 · 10 comments
Closed

The static import statement shows "Resolve error: Missing binary" #1175

midorizemi opened this issue Feb 4, 2021 · 10 comments
Labels
info-needed Issue requires more information from poster

Comments

@midorizemi
Copy link

midorizemi commented Feb 4, 2021

vscode-eslint is working my react application project on working directory.
It, however, fails to find fibers package via vscode. I cant find a solution yet. please help me.

Here is my repository. https://github.com/midorizemi/react-sample.git

My environments:

  • Windows10 64bit
  • nvm v1.1.7 via scoop
  • node v14.15.4
  • npm v6.14.10

I installed npm packages, and open vscode, and add ESLint plugin in vscode.
When I typed "import" first line, vscode-eslint said the error.
スクリーンショット 2021-02-04 150421

I, however, tried to run npm run fix:lint. I didn't get any error like the error.

PS C:\Users\Public\react\sample-react> npm run fix:lint

> webpack-react-demo@ fix:lint C:\Users\Public\react\sample-react
> eslint --fix "./{lib,src,test}/**/*.{ts,tsx}"

This is the full infomation of the error from "PROBLEMS" form vscode.

{
	"resource": "/c:/Users/Public/react/sample-react/src/main.tsx",
	"owner": "eslint",
	"code": {
		"value": "import/extensions",
		"target": {
			"$mid": 1,
			"external": "https://github.com/benmosher/eslint-plugin-import/blob/v2.22.1/docs/rules/extensions.md",
			"path": "/benmosher/eslint-plugin-import/blob/v2.22.1/docs/rules/extensions.md",
			"scheme": "https",
			"authority": "github.com"
		}
	},
	"severity": 8,
	"message": "Resolve error: Missing binary. See message above.\n    at Object.<anonymous> (C:\\Users\\Public\\react\\sample-react\\node_modules\\fibers\\fibers.js:23:9)\n    at Module._compile (internal/modules/cjs/loader.js:1014:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1051:10)\n    at Module.load (internal/modules/cjs/loader.js:862:32)\n    at Module._load (internal/modules/cjs/loader.js:774:14)\n    at Function.Module._load (electron/js2c/asar.js:769:28)\n    at Module.require (internal/modules/cjs/loader.js:899:19)\n    at require (internal/modules/cjs/helpers.js:74:18)\n    at Object.<anonymous> (C:\\Users\\Public\\react\\sample-react\\webpack.config.js:60:24)\n    at Module._compile (internal/modules/cjs/loader.js:1014:30)",
	"source": "eslint",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 1
}

Although I delete node_modules and reinstall npm packages, that doesn't work.
thank you.

@dbaeumer
Copy link
Member

dbaeumer commented Feb 4, 2021

This works for me:

capture

Are you sure your system is setup so that binaries can be complied on npm install

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Feb 4, 2021
@dbaeumer
Copy link
Member

dbaeumer commented Feb 4, 2021

And what happens if you execute ./node_modules/.bin/eslint src/main.tsx in a terminal.

@midorizemi
Copy link
Author

midorizemi commented Feb 4, 2021

Thank you so much for quick response.

Are you sure your system is setup so that binaries can be complied on npm install

yes, I am.
I've uninstalled nvm from scoop, and, installed nodejs-lts(14.15.4) via scoop.
Then I've executed npm install, and I've ensured that was completed again.
image

I've executed ./node_modules/.bin/eslint src/main.tsx, and It didn't put anything.
image

I've reopend VSCode, however, It didn't work.
image

And I've reinstalled vscode-eslint and uninstalled the others, then I replaced setting.json as follow.

{
    "[javascript,javascriptreact,javascriptreact,typescript,typescriptreact,json]": {
        "editor.tabSize": 2,
    },
    "[javascriptreact,typescript,typescriptreact]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.fixAll.eslint": true
        },
    },
    "typescript.updateImportsOnFileMove.enabled": "always",
    "javascript.updateImportsOnFileMove.enabled": "always",
    "typescript.format.insertSpaceAfterTypeAssertion": true,
    "eslint.alwaysShowStatus": true,
    "eslint.probe": [
        "javascript",
        "javascriptreact",
        "typescript",
        "typescriptreact",
        "html",
        "vue",
        "markdown",
        "react"
    ],
    "eslint.workingDirectories": [
        { "mode": "auto" }
    ],
    "terminal.integrated.env.windows": {
        "PATH": "${workspaceRoot}\\node_modules\\.bin;${env:PATH}"
    },
}

However, It still didn't work..

@dbaeumer
Copy link
Member

dbaeumer commented Feb 4, 2021

Wild guess: can you use node as the runtime for eslint by using the setting eslint.runtime. Could be the the node shipped with Electron is not capable of executing / loading the binary.

@midorizemi
Copy link
Author

It works! Thank you so much!
I added the settings eslint.runtime to setting.json as follows and restarted VS Code.

"eslint.runtime": "C:\\Users\\midorizemi\\scoop\\apps\\nodejs-lts\\14.15.4\\node.exe",

The runtime path is "Environment:" from scoop info nodejs-lts.

I don't understand yet why the node included in Electron cannot executing / loading the binary, although, This issue was solved.
Thank you so much for your support again, @dbaeumer!

@dbaeumer
Copy link
Member

dbaeumer commented Feb 5, 2021

The problem is that when you install the package it is complied against the node version you have installed (which in you case is 14.15.4). Electron ships node version 12.18.3 and the binary compiled for 14.15.4 can't be loaded / executed in 12.18.3.

I know, not something a user usually wants to deal with :-)

@midorizemi
Copy link
Author

Thank you for additional information.
I can understand the cause finally.
But Can I ask a question?
When I used VSCode in other OS environments (Ubuntu, etc.), I installed 12.18.3 version of node to develop, and in that environment, I was able to load it without any problems like this.
I'm sorry I don't have that knowledge at all.
Does this mean that the version of node provided by Electron is different due to the difference in distributions?

@dbaeumer
Copy link
Member

dbaeumer commented Feb 8, 2021

No it is not. The problem is that binaries are node version dependent. So if you install 12.18.3 it will work since the binaries are built against the right node API surface.

@midorizemi
Copy link
Author

Oh. I understand. Thank you so much.

@midorizemi
Copy link
Author

Due to the fact that I moved my development environment from Windows to Mac M1, I encountered the same problem again.

I had set eslint.runtime as "eslint.runtime":"/Users/midorizemi/.anyenv/envs/nodenv/shims/node", but eslint showed the same error as the issue. However, eslint showed the same error as the issue.

I was not able to explore the issue in depth, but it seems that .anyenv shims in "eslint.runtime" cannot select and run the version of node according to the .node-versions in the project directory.

Finally, I worked around this problem by explicitly specifying the version of the executable specified in the project.

// folder/setting.json
"eslint.runtime": "/Users/midorizemi/.anyenv/envs/nodenv/versions/14.17.1/bin/node",

This may not be relevant to this project, but I hope it is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants