sublimelsp / LSP-json

Schema validation/completions for your JSON and Sublime files
MIT License
75 stars 9 forks source link

lsp-json init error #159

Closed h-polaris closed 1 year ago

h-polaris commented 1 year ago

I just opened a JSON file and encountered an error during the initialization process.

image

Failed to start LSP-json - disabling for this window for the duration of the current session.
Re-enable by running "LSP: Enable Language Server In Project" from the Command Palette.

--- Error: ---
Error installing the server:
Failed to run npm command "ci --omit=dev --scripts-prepend-node-path=true --verbose":
npm verb cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@9.6.7
npm info using node@v18.17.0
npm verb title npm ci
npm verb argv "ci" "--omit" "dev" "--scripts-prepend-node-path" "true" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:/Users/xxx/.npm/_logs/2023-08-08T17_39_16_335Z-
npm verb logfile /Users/xxx/.npm/_logs/2023-08-08T17_39_16_335Z-debug-0.log
npm http fetch POST 501 https://registry.npmmirror.com/-/npm/v1/security/advisories/bulk 224ms
npm http fetch GET 200 https://cdn.npmmirror.com/packages/%40vscode/l10n/0.0.13/l10n-0.0.13.tgz 260ms (cache miss)
npm http fetch POST 501 https://registry.npmmirror.com/-/npm/v1/security/audits/quick 62ms
npm verb audit error HttpErrorGeneral: 501 Not Implemented - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick - [NOT_IMPLEMENTED] /-/npm/v1/security/audits/quick not implemented yet
npm verb audit error     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
npm verb audit error     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm verb audit error     at async [getReport] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:335:21)
npm verb audit error     at async AuditReport.run (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:106:19)
npm verb audit error  HttpErrorGeneral: 501 Not Implemented - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick - [NOT_IMPLEMENTED] /-/npm/v1/security/audits/quick not implemented yet
npm verb audit error     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/lib/check-response.js:95:15
npm verb audit error     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm verb audit error     at async [getReport] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:335:21)
npm verb audit error     at async AuditReport.run (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:106:19) {
npm verb audit error   headers: [Object: null prototype] {
npm verb audit error     server: [ 'Tengine' ],
npm verb audit error     'content-type': [ 'application/json; charset=utf-8' ],
npm verb audit error     'content-length': [ '81' ],
npm verb audit error     connection: [ 'keep-alive' ],
npm verb audit error     'strict-transport-security': [ 'max-age=5184000' ],
npm verb audit error     date: [ 'Tue, 08 Aug 2023 17:39:16 GMT' ],
npm verb audit error     vary: [ 'Origin' ],
npm verb audit error     'request-id': [ '7f5df7c0-3612-11ee-b97d-076833350901' ],
npm verb audit error     'x-frame-options': [ 'SAMEORIGIN' ],
npm verb audit error     'x-xss-protection': [ '1; mode=block' ],
npm verb audit error     'x-content-type-options': [ 'nosniff' ],
npm verb audit error     'x-download-options': [ 'noopen' ],
npm verb audit error     'x-readtime': [ '0.57' ],
npm verb audit error     'x-alicdn-da-ups-status': [ 'endOs,0,501' ],
npm verb audit error     via: [ 'kunlun20.cn5114[34,0]' ],
npm verb audit error     'timing-allow-origin': [ '*' ],
npm verb audit error     eagleid: [ 'dcb57d1b16915163569088794e' ],
npm verb audit error     'x-fetch-attempts': [ '1' ]
npm verb audit error   },
npm verb audit error   statusCode: 501,
npm verb audit error   code: 'E501',
npm verb audit error   method: 'POST',
npm verb audit error   uri: 'https://registry.npmmirror.com/-/npm/v1/security/audits/quick',
npm verb audit error   body: {
npm verb audit error     error: '[NOT_IMPLEMENTED] /-/npm/v1/security/audits/quick not implemented yet'
npm verb audit error   },
npm verb audit error   pkgid: undefined
npm verb audit error }
npm http fetch GET 200 https://cdn.npmmirror.com/packages/vscode-uri/3.0.7/vscode-uri-3.0.7.tgz 272ms (cache miss)
npm verb stack Error: EACCES: permission denied, mkdir '/Users/xxx/.npm/_cacache/content-v2/sha512/78/ea'
npm verb cwd /Users/xxx/Library/Caches/Sublime Text/Package Storage/LSP-json/18.17.0/language-server
npm verb Darwin 22.1.0
npm verb node v18.17.0
npm verb npm  v9.6.7
npm ERR! code EEXIST
npm ERR! syscall mkdir
npm ERR! path /Users/xxx/.npm/_cacache/content-v2/sha512/78/ea
npm ERR! errno -13
npm ERR! EACCES: permission denied, mkdir '/Users/xxx/.npm/_cacache/content-v2/sha512/78/ea'
npm ERR! File exists: /Users/xxx/.npm/_cacache/content-v2/sha512/78/ea
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm verb exit -13
npm verb unfinished npm timer reify 1691516356460
npm verb unfinished npm timer reify:unpack 1691516356466
npm verb unfinished npm timer reifyNode:node_modules/vscode-uri 1691516356466
npm verb unfinished npm timer reifyNode:node_modules/vscode-json-languageservice/node_modules/@vscode/l10n 1691516356466
npm verb code -13

npm ERR! A complete log of this run can be found in: /Users/xxx/.npm/_logs/2023-08-08T17_39_16_335Z-debug-0.log

How can I solve it?

rchl commented 1 year ago

It looks like you are using a mirror npm registry that doesn't support some features of NPM (auditing):

npm verb audit error HttpErrorGeneral: 501 Not Implemented - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick - [NOT_IMPLEMENTED] /-/npm/v1/security/audits/quick not implemented yet

This is probably configured in ~/.npmrc.

Not sure if this error is critical or not because later you are also getting another error:

npm http fetch GET 200 https://cdn.npmmirror.com/packages/vscode-uri/3.0.7/vscode-uri-3.0.7.tgz 272ms (cache miss)
npm verb stack Error: EACCES: permission denied, mkdir '/Users/xxx/.npm/_cacache/content-v2/sha512/78/ea'

I don't know why would it fail to create the directory but there seems to be something wrong with your directory permissions. Maybe you are in a restricted environment (work laptop) where installing new packages is blocked?

If you want to, you can try to work around that by using LSP-specific node instance:

  1. Open Preferences: LSP Utils Settings from the Command Palette
  2. Set those options on the right side:
    // Settings in here override those in "lsp_utils/lsp_utils.sublime-settings"
    {
    "nodejs_runtime": ["local"],
    }
  3. Restart ST
h-polaris commented 1 year ago

I still made an error after trying. How should I give him permission?

rchl commented 1 year ago

What is the new error?

h-polaris commented 1 year ago

The error is the same as before.

rchl commented 1 year ago

Can't be exactly the same since the paths would have to change at least with my suggested change. Please post the new error.

h-polaris commented 1 year ago

I solved this problem by giving .npm directory permissions.