Closed dzid26 closed 4 months ago
I suspect you have a bad development environment. Please fully recreate (and ensure caches don't interfere). If you still experience problems, let me know!
Best regards, -Joe
I was able to narrow it down to this (my own) commit https://github.com/jbenden/vscode-c-cpp-flylint/commit/2292ee293dd652d0a723a9a88f0c2d8575bdf482.
Did I import JSON5 incorrectly?
import JSON5 = require('json5');
, but it didn't help:
TypeError: _.parse is not a function
at N (c:\Users\dzidm\.vscode\extensions\jbenden.c-cpp-flylint-1.12.1\server\out\server.js:2:18495)
at async Function.B (c:\Users\dzidm\.vscode\extensions\jbenden.c-cpp-flylint-1.12.1\server\out\server.js:2:20366)
Could not find or parse the workspace c_cpp_properties.json file; continuing...
import JSON5 from 'json5'
gives me linter error: Module '"json5"' has no exported member 'JSON5
Or could it be related to this https://stackoverflow.com/questions/71586851/typeerror-json5-parse-is-not-a-function? Someone said it's some VScode issue.
Try the import at the top of the file as:
import { parse as jsonParse } from 'json5';
And also edit the usage line from JSON5.parse
to jsonParse
.
https://github.com/jbenden/vscode-c-cpp-flylint/blob/main/server/src/server.ts#L5
Unfortunately, this produces the same error:
Could not find or parse the workspace c_cpp_properties.json file; continuing...
TypeError: _.parse is not a function
at N (c:\Users\dzidm\.vscode\extensions\jbenden.c-cpp-flylint-1.12.1\server\out\server.js:2:18495)
at async Function.B (c:\Users\dzidm\.vscode\extensions\jbenden.c-cpp-flylint-1.12.1\server\out\server.js:2:20366)
I just installed and tested this extension and I get the same error...
Could not find or parse the workspace c_cpp_properties.json file; continuing...
TypeError: r.parse is not a function
at N (c:\Users\user\.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:2:18495)
at async B (c:\Users\user\.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:2:20366)
at async c:\Users\user\.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:2:24847
I get the same error, too. Any update on this issue?
Could not find or parse the workspace c_cpp_properties.json file; continuing...
TypeError: r.parse is not a function
at N (/home/user/.vscode-server/extensions/jbenden.c-cpp-flylint-1.13.0/server/out/server.js:2:18495)
at async Function.B (/home/user/.vscode-server/extensions/jbenden.c-cpp-flylint-1.13.0/server/out/server.js:2:20366)
Since the problem doesn't appear when debugging, I turned off modification by changing this:
"webpack": "npm run clean && webpack --config ./client/webpack.config.js && webpack --config ./server/webpack.config.js",
so that the error function can be seen properly.
After that I compiled with vsce package
and installed from extensions sidebar.
Now I am getting:
Could not find or parse the workspace c_cpp_properties.json file; continuing...
TypeError: JSON5.parse is not a function
at getCppProperties (c:\Users\dzidm\.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:198:42)
at async Function.validateTextDocument (c:\Users\dzidm\.vscode\extensions\jbenden.c-cpp-flylint-1.13.0\server\out\server.js:377:20)
And here is the Javascript file.
So it compiles to something very similar that we had one commit earlier https://github.com/jbenden/vscode-c-cpp-flylint/blame/78c48ffe0a27111ba731e2f930b99d56cde8e566/server/src/server.ts#L235-L236 But I don't know what is wrong with calling JSON5.parse().
Maybe similar issues: https://github.com/json5/json5/issues/287 https://github.com/misskey-dev/misskey/issues/10955 https://github.com/json5/json5/pull/241 Seems like there is more talk regarding webpack issue https://github.com/microsoft/vscode/issues/130367 Also https://github.com/electron/electron/issues/21457#issuecomment-1667909379. I don't know if this really relates. I was under the impression that some people don't experience this.
Ok, I kind of fixed it but it is dumb.
Based on this I created index.mjs.d in vscode-c-cpp-flylint\node_modules\json5\dist
Then replaced:
https://github.com/jbenden/vscode-c-cpp-flylint/blob/2d5699303e7b069b940fa2cb09fd6bfe3f687a9c/server/src/server.ts#L5
with
import JSON5 from 'json5/dist/index.mjs'
And
https://github.com/jbenden/vscode-c-cpp-flylint/blob/2d5699303e7b069b940fa2cb09fd6bfe3f687a9c/server/src/server.ts#L236
with
const cCppProperties: IConfigurations = JSON5.parse((fs.readFileSync(cCppPropertiesPath, 'utf8')));
Then run vsce package
and installed.
Here is compiled vsix of the latest v1.13.0.
@jbenden Maybe the release could be updated the same way.
that vsix seems to do the job for me. cheers man
Same error,and vsix work for me. Maybe create a pr to fix it?
Please include this in an official release 👍
I've got annoyed with this issue again. But I think I found a better solution that can be integrated - https://github.com/jbenden/vscode-c-cpp-flylint/pull/217 In the meantime, here is a packaged extension based on latest version c-cpp-flylint-1.14.0.vsix.zip
A commit was made to resolve this matter. It is pending release, though.
This error is for the version from the marketplace or packaged locally using with
npm run compile && vsce package
from the latest commit or release commit. In debug mode (F5) the problem is NOT happening!