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

Cannot find module 'vscode' – where is vscode.d.ts now installed? #2810

Closed
jednano opened this issue Feb 9, 2016 · 12 comments
Closed

Cannot find module 'vscode' – where is vscode.d.ts now installed? #2810

jednano opened this issue Feb 9, 2016 · 12 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@jednano
Copy link

jednano commented Feb 9, 2016

The January Release Notes – Extension Authoring section says I should be able to update my package.json file to include the following:

{
  "engines": {
    "vscode": "^0.10.8"
  },
  "devDependencies": {
    "typescript": "^1.7.5",
    "vscode": "^0.11.x"
  }
}  

It also notes the following:

  • The vscode.d.ts is no longer shipping within the vscode npm module.
  • The value of the engine field in your extension is used to determine which version of vscode.d.ts to use.

It does not, however, tell me where vscode.d.ts is installed. I used to be able to do imports like:

import { TextEditor } from 'vscode';

However, now I'm getting an error:

Cannot find module 'vscode'.

It's not clear to me, the new way to do these imports and I've tried tracking down vscode.d.ts to no avail, so I'm at a loss.

@bpasero
Copy link
Member

bpasero commented Feb 9, 2016

@jedmao you need to run a "npm install" after those changes so that the vscode.d.ts is fetched. The location of this file actually did not change, it should still be within node_modules/vscode/vscode.d.ts

@jednano
Copy link
Author

jednano commented Feb 9, 2016

@bpasero one step ahead of you. Not only did I run npm install after those steps, but after it wasn't working, I did npm uninstall vscode and then npm install again, just to make sure. There is no file at node_modules/vscode/vscode.d.ts, even though node_modules/vscode/package.json has within it:

  "typings": "vscode.d.ts",

The closest thing I could find was a file at node_modules/vscode/typings/index.d.ts, but I don't think that's what I want.

@jednano
Copy link
Author

jednano commented Feb 9, 2016

@bpasero I also did an npm cache clean just now, deleted my node_modules folder and did a fresh npm install. Same issue.

@alexandrudima, do you know more about this? I'm looking at https://github.com/Microsoft/vscode-editorconfig/blob/master/typings/vscode-typings.d.ts with your name on it.

@bpasero
Copy link
Member

bpasero commented Feb 9, 2016

@jedmao there was a bug that prevented the vscode.d.ts file to be installed. When you run npm install please verify you see output like this:

Detected VS Code engine version: ^0.10.6
Found minimal version that qualifies engine range: 0.10.6
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/0.10.6/src/vs/vscode.d.ts
vscode.d.ts successfully installed!

@bpasero bpasero closed this as completed Feb 9, 2016
@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Feb 9, 2016
@bpasero bpasero added this to the Feb 2016 milestone Feb 9, 2016
@mattacosta
Copy link
Contributor

Wanted to try and reproduce the problem here just for fun, so I uninstalled vscode from one of my existing, and perfectly functioning extensions, then followed the instructions listed on that page and updated the devDependencies of its package.json file to ^0.11.1. After running npm install however, the vscode.d.ts file was still no where to be found...

So I ran node ./node_modules/vscode/bin/install manually an got:
Error installing vscode.d.ts: Missing VSCode engine declaration in package.json.

Looked at the install script, figured that NPM package vars weren't set for some reason, then added this script to my package.json:
"pkgvars": "node ./node_modules/vscode/bin/install"

Using npm run pkgvars resulted in a successful download. shrug

@bpasero bpasero assigned joaomoreno and unassigned bpasero Feb 9, 2016
@jednano
Copy link
Author

jednano commented Feb 9, 2016

@bpasero I definitely don't see the output you pasted above. I even tried changing my engine from ^0.10.8 to ^0.10.6 to make sure my settings were consistent w/ yours and still no output like that.

Then, I tried changing my vscode dev dependency from ^0.11.x to 0.11.1 like @mattacosta did above and I'm still not seeing your output.

Is there always going to be an engine version consistent with the version displayed in Visual Studio Code -> Help -> About?

Lastly, you said there "was" a bug. That gave me more qeustions:

  1. Does that mean this bug was fixed?
    1. Was it fixed in the February milestone?
      1. How does that help me now or how can I take advantage of that now?
      2. Do I need to wait until the February release to use the ^0.11.x vscode dev dependency? If so, perhaps the January release notes need to be updated to inform others of the same issue.
  2. Do you have more details about this bug or can you link me the issue?

@mattacosta
Copy link
Contributor

The vscode devDependency is for the vscode node package. This is not the same as the VS Code application, which is managed separately. So it has nothing to do with any Jan/Feb/whenever release, and is available now.

Also, here's the issue that was fixed in 0.11.1: microsoft/vscode-extension-vscode#10

Have you tried running vscode's install script from your package.json though?

@jednano
Copy link
Author

jednano commented Feb 10, 2016

@mattacosta I'm aware that vscode is just an npm package. My question was concerning the engine setting.

I didn't run vscode's install script from package.json, because I'm not interested in that solution. I'm interested in solutions that don't require adding instructions to my README and work out-of-the-box for future contributors. Now, if you're suggesting I make it a post install script, that might be doable, but the release notes and guides don't say anything about this and I'd prefer to follow the golden path.

That said, I'm going to attempt using the post install script until this project evolves. Thanks for the link to the issue!

@bpasero
Copy link
Member

bpasero commented Feb 10, 2016

Sorry, I realised that I did not mention the necessary postinstall script. I updated the new & noteworthy. Any extension consuming the VS Code npm module 0.11.x needs to add the following to the package.json:

"scripts": {
    "postinstall": "node ./node_modules/vscode/bin/install"
}

@jednano
Copy link
Author

jednano commented Feb 10, 2016

It works!

> EditorConfig@0.2.1 postinstall z:\Documents\GitHub\vscode-editorconfig
> node ./node_modules/vscode/bin/install

Detected VS Code engine version: ^0.10.8
Found minimal version that qualifies engine range: 0.10.8
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/0.10.8/src/vs/vscode.d.ts
vscode.d.ts successfully installed!

Still, I think others could well benefit from this in the release notes, right where it mentions the ^0.11.x dev dependency.

@joaomoreno joaomoreno added the verified Verification succeeded label Feb 26, 2016
@codekhol
Copy link

Why don't you add vscode.d.ts to DefinitelyTyped?

@bpasero
Copy link
Member

bpasero commented Mar 18, 2016

Because it does not support versioning...

Levertion added a commit to Levertion/mcfunction-language-server that referenced this issue Nov 9, 2017
The postinstall script in the client package is because of: microsoft/vscode#2810 (comment)
Package locks added as Node needed updating to get them.
Tsconfig changed in attempted troubleshooting step until I found microsoft/vscode#2810
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants