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

Code Insider complains "Could not install typings files for JS/TS language features. Please ensure that NPM is installed" #24961

Closed
HungryJake opened this issue Apr 18, 2017 · 154 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug javascript JavaScript support issues typescript Typescript support issues verified Verification succeeded
Milestone

Comments

@HungryJake
Copy link

  • VSCode Version: Insider (daily latest, 1.12.0)
  • OS Version: Mac OS X 10.12.4

Steps to Reproduce:

  1. I've nvm, node, and npm installed the current version in the system.
  2. Open Code Insider
  3. Open any existing JavaScript (ES) node project, warning appears:
    "Could not install typings files for JS/TS language features. Please ensure that NPM is installed"
@mjbvz mjbvz self-assigned this Apr 18, 2017
@mjbvz mjbvz added javascript JavaScript support issues typescript Typescript support issues info-needed Issue requires more information from poster labels Apr 18, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Apr 18, 2017

Can you please share the output from running:

$ which npm
$ npm --version

in your terminal

@TheSisb
Copy link

TheSisb commented Apr 19, 2017

Same error

~ which npm
/usr/local/bin/npm
➜  ~ npm --version
4.0.5

That said, I don't use TS. The error led me here.

@mjbvz
Copy link
Contributor

mjbvz commented Apr 19, 2017

TypeScript powers both our JavaScript and TypeScript language features.

To diagnose this, can you please try collecting the tsserver log:

  • Set "typescript.tsserver.log": "verbose",
  • Restart VSCode and reproduce the issue
  • Run the TypeScript: Open TS Server log file command and share the log file
  • Also reveal the location of the log file in the finder. There should be a ti-xxx.log file next to it with information about typings install

⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

@wprater
Copy link
Contributor

wprater commented Apr 19, 2017

having the same issue with code-insiders and n node manager.

however, I think its related to this issue #10876 and if I open from the CLI, the issue does not persist.

@mjbvz mjbvz removed the info-needed Issue requires more information from poster label Apr 20, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Apr 20, 2017

I've opened microsoft/TypeScript#15287 to track typings install issues when using n/nvm. If you run into this, as a workaround, try fully restarting VSCode. If you are running from the command prompt, also restart that. This should ensure that VSCode is using the current PATH. (#23649 tracks re-reading the environment for each new VSCode window)

@DrkCoater / TheSisb Are you using n or nvm? Can you also try restarting VSCode fully to see if you are also running into a PATH issue

@HungryJake
Copy link
Author

HungryJake commented Apr 20, 2017

My npm is in path actually, although I'm also using nvm. I have already restarted my machine as well as Code fully serval times. The warning still coming up. I think it only happened since an update some time last week, it didn't happen before. thanks

which npm:
~/.nvm/versions/node/v7.8.0/bin/npm
npm --version
4.2.0

@HungryJake
Copy link
Author

HungryJake commented Apr 20, 2017

And I found this related log message from the tsserver.log according to your procedures:

Info 29 Received response: {"kind":"event::initializationFailed","message":"Command failed: npm install types-registry"}
Info 30 event: {"seq":0,"type":"event","event":"typesInstallerInitializationFailed","body":{"message":"Command failed: npm install types-registry"}}

@mjbvz mjbvz added the bug Issue identified by VS Code Team member as probable bug label Apr 20, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Apr 24, 2017

Yes, we added this warning message recently to catch cases just like this. When typescript cannot find npm, automatic typing acquisition will not work. #25112 added a way to disable this warning if it is getting in the way.


@DrkCoater Can you open the developer console (Help -> Toggle Developer Tools) and evaluate process.env['PATH'] in the console. I suspect that nvm's path is not in there.

If this is the case, try running code from the command line to ensure the proper PATH is picked up. #15452 and #23649 both track ensuring that we load the proper environment when launching VSCode

@mjbvz
Copy link
Contributor

mjbvz commented Apr 24, 2017

@joaomoreno Any thoughts on ensuring we pick up the PATH from a user's .bashrc?

@joaomoreno
Copy link
Member

joaomoreno commented Apr 25, 2017

We already do it.

@DrkCoater says

I think it only happened since an update some time last week, it didn't happen before.

And I agree with him. This already happened to me twice, and only after an update. So it has something to do with how Squirrel reinitialises the app once updated. For sure it didn't happen before lazyEnv was introduced. cc @jrieken

@jrieken
Copy link
Member

jrieken commented Apr 25, 2017

For sure it didn't happen before lazyEnv was introduced. cc @jrieken

What make you so sure about that? The only thing we do while lazyEnv is working is loading code, the extension host gets its environment only when being started

@joaomoreno
Copy link
Member

A feeling. It could also be a coincidence that this message appeared at around roughly the same time.

@HungryJake
Copy link
Author

@mjbvz FYI, for process.env['PATH'], my path is actually there:
/.../bin:/.../.nvm/versions/node/v7.8.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
my node executable is at: /.../.nvm/versions/node/v7.8.0/bin

@wprater
Copy link
Contributor

wprater commented Apr 26, 2017

And I agree with him. This already happened to me twice, and only after an update. So it has something to do with how Squirrel reinitialises the app once updated. For sure it didn't happen before lazyEnv was introduced. cc @jrieken

Even after an update, if I quite and re-open the app normally the issues persists. If I open from the CLI, then it will go away and my PATH is correct.

@chrmarti
Copy link
Contributor

  • VSCode Version: Code - Insiders 1.12.0-insider (48ae6e3, 2017-04-26T06:32:53.505Z)
  • OS Version: Linux x64 3.13.0-108-generic
  • Extensions: none

This reproduces after each start from the dock on Ubuntu. ATA still works afterwards, probably from the existing .d.ts cache. process.env['PATH'] is missing n's path that is added in .bashrc.

The reason for this is process.env['VSCODE_CLI'] being set, which makes shellEnv.ts skip getUnixShellEnvironment(). I don't see why that is set though. When I open a (non-VSCode) terminal VSCODE_CLI is not set.

image

@jrieken
Copy link
Member

jrieken commented Apr 27, 2017

The reason for this is process.env['VSCODE_CLI'] being set,

Whooot 😱

@chrmarti
Copy link
Contributor

@joaomoreno @jrieken @Tyriar Any idea why process.env['VSCODE_CLI'] might be set on my when starting from the dock in Ubuntu? ATA not working will be annoying to JavaScript users.

@jrieken
Copy link
Member

jrieken commented Apr 27, 2017

This should only be set when launching via scripts/code.[sh|bat]. I see a reference in cli.ts of which @joaomoreno might know more?

@joaomoreno
Copy link
Member

I have no clue. Something must be setting it in your system... Weird.

@Tyriar Tyriar self-assigned this Apr 27, 2017
@Tyriar
Copy link
Member

Tyriar commented Apr 27, 2017

VSCODE_CLI is set for the window when it's launched from the CLI https://github.com/Microsoft/vscode/blob/c5df2b09b339868e3ae1dcec907fa793a14bc79e/src/vs/code/node/cli.ts#L42, ie. retain the shell environment.

I accepted a pull request this iteration that changed the desktop entry to launch through the CLI: #24523, #10091

So reading through these issues it looks like here is what is going on:

The obvious fix here is to move the ATA PATH setup to .bash_profile which is run when logging in for Linux. Thoughts?

@Tyriar Tyriar added this to the April 2017 milestone Apr 27, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Apr 27, 2017

We don't do anything specific to set up ATA. All we need is a PATH that has npm somewhere.

On my Mac and Ubuntu test machines at least, nvm only added itself to the ~/.bashrc and not to the ~/.bash_profile

@bernljung
Copy link

@chrmarti I'm not running as root, in fact OS X Sierra makes it hard to even edit /usr/bin and the likes due to System Integrity Protection...

Permissions are 755 with root:wheel as owner.

@chrmarti
Copy link
Contributor

@bernljung Your previous comment says /usr/sbin which is usually only used by root. Was that a typo? How did you install npm there?

@bernljung
Copy link

I've tried both. Npm is installed in /usr/local/bin/npm and then symlinked to /usr/bin/npm and /usr/sbin/npm. (for VSC testing only)

@viktor-wolf
Copy link

viktor-wolf commented Sep 8, 2017

I'm still getting this issue on v1.16 running on Antergos.
Running which npm in the integrated terminal outputs: /home/viktor/.nvm/versions/node/v8.4.0/bin/npm. I have set my typescript.npm setting to this path, but it didn't fix the issue. I have also tried running VS Code from bash, but it didn't help.
Here is my ti log file (I changed the extension to txt, because GitHub doesn't support upload for .log): ti-6028.txt

@mjbvz
Copy link
Contributor

mjbvz commented Sep 8, 2017

Thanks @viktor-wolf! I've opened microsoft/TypeScript#18344 to track this failure. Can you please try running "/home/viktor/.nvm/versions/node/v8.4.0/bin/npm" install --ignore-scripts types-registry on the command line and posting the output to the new issue

@nickytonline
Copy link

The only way I can get this to work is by launching VS Code via the command line, https://code.visualstudio.com/docs/setup/mac. If I open it from the Dock on OS X, it always gives this error, even when adding "typescript.npm": "/usr/local/bin/npm"

@viktor-wolf
Copy link

@nickytonline Thanks for the tip. I tried launching Code from CLI and it didn't show the error. After that initial CLI launch I no longer get it even when I launch from a shortcut. However, I'm not sure if the underlying problem got fixed, since I still have the types-registry error in my ts log.

@nickytonline
Copy link

@viktor-wolf, I'll check my logs when I have a chance to see if it still persisted.

@viktor-wolf
Copy link

viktor-wolf commented Sep 26, 2017

Actually, disregard my previous comment. I just went to change some preferences and I noticed that the typescript check was disabled ("typescript.check.npmIsInstalled": false). I must have misclicked on the "Don't check again" option at some point without noticing. After removing this setting I started getting the warning again, whether I run Code from terminal or not.

@rhzs
Copy link

rhzs commented Oct 5, 2017

Still have the problem with new version 1.16.1

What should I do? @mjbvz

$ /Users/angel/.nvm/versions/node/v8.5.0/bin/npm  install --ignore-scripts types-registry
npm ERR! path /Users/angel/abx/node_modules/.staging/types-registry-38e9fd4a/
npm ERR! code EISDIR
npm ERR! errno -21
npm ERR! syscall open
npm ERR! EISDIR: illegal operation on a directory, open '/Users/angel/abx/node_modules/.staging/types-registry-38e9fd4a/'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/angel/.npm/_logs/2017-10-05T16_57_51_693Z-debug.log

@Spown
Copy link

Spown commented Oct 5, 2017

I've just updated tsc from 2.5.2 to 2.5.3 and the warning seems gone now...

@tgreen7
Copy link

tgreen7 commented Oct 5, 2017

I upgraded typescript to 2.5.3 and am still seeing this.

@Spown
Copy link

Spown commented Oct 5, 2017

I also moved npm higher (to the left) in the PATH var. maybe it did the trick... seeing it again. wierd. I restarted VSC trice and only the third time I got this message again.

@VinceOPS
Copy link

VinceOPS commented Oct 5, 2017

Having the issue too, VSCode 1.6.1, npm 4.6.1, typescript 2.5.3, running on Debian.

@Spown
Copy link

Spown commented Oct 5, 2017

and its gone again. just restarted VSC like 8 times. my guess is it sends a request to the typings repository. and probably because of the load gets no/error response. shows a wrong error though.

@bepvte
Copy link
Contributor

bepvte commented Oct 5, 2017

I temporarily solved it by running sudo npm install -g types-registry

@kylejw1
Copy link

kylejw1 commented Oct 5, 2017

I just ran into this issue. I also had an issue running:
npm install -g --ignore-scripts types-registry

I created the .staging directory manually, then the npm install was successful and the message went away:
mkdir -p ~/.nvm/versions/node/v8.6.0/lib/node_modules/.staging

Version 1.17.0-insider
f6ef4be

@SharakPL
Copy link
Contributor

SharakPL commented Oct 5, 2017

Could not install typings files for JavaScript language features. Please ensure that NPM is installed or configure 'typescript.npm' in your user settings

I've just got this warning on my VSCode (1.16.1 updated few weeks ago) after updating npm from 5.4.2 to 5.5.1 with npm update -g. My settings are default (i think):

"typescript.npm": null,
"typescript.check.npmIsInstalled": true,

@SharakPL
Copy link
Contributor

SharakPL commented Oct 5, 2017

Got back to npm 5.4.2 with npm install -g npm@latest and warning stopped showing up :)

@bojand
Copy link

bojand commented Oct 5, 2017

Started getting this as well with the stock node 8.6.0 and stock npm 5.3.0 installed via the Node.js installer.

In TS Server log:

Info 34   [15:4:27.228] Received response: {"kind":"event::initializationFailed","message":"Command failed: npm install --ignore-scripts types-registry"}
Info 35   [15:4:27.228] event: {"seq":0,"type":"event","event":"typesInstallerInitializationFailed","body":{"message":"Command failed: npm install --ignore-scripts types-registry"}}

Of important note is that we use internal npm registry at work (not sure what's the provider, but it's not NPM Inc.) so my ~/.npmrc:

; My private settings for public npm
;//registry.npmjs.org/:{auth stuff}

; Work settings
registry=http://{internal corp npm repo}
_auth={auth info}
email={email}

When I use the public one VSCode works fine. When I comment out the public one and use the internal one I get the error. This used to work without issues forever, so not sure what happened all of a sudden to cause it. It seems types-registry package was updated 48 minutes ago. So it may be a case where the mirror is lagging behind in getting it / syncing with the public npm. I will keep an eye on this and see if it goes away out of the blue, which may indicate this is the issue. Just posting so others may be aware that this could be the cause if they're using a private mirror or some similar setup.

[EDIT] Update. The error went away after a little while as our mirror picked up the new types-registry

@jasonpolites
Copy link

Any idea why this issue is closed? I get the same error on a fresh install of VSC. I'm using nvm via linux subsystem (Ubuntu) on Win 10

@mjbvz
Copy link
Contributor

mjbvz commented Oct 17, 2017

@jasonpolites Please open a new issue if you don't see this working. Also, have you looked through the documentation on this: https://code.visualstudio.com/Docs/languages/javascript#_fixing-npm-not-installed-warning-for-automatic-type-acquisition

@jasonpolites
Copy link

I will open a new issue as I've run out of things to try (including the aforementioned docs). Thanks!

@Ashleycodesseo
Copy link

I'm also getting this error message. Can anyone give instructions in plain english how to fix this?

@microsoft microsoft locked and limited conversation to collaborators Nov 8, 2017
@mjbvz
Copy link
Contributor

mjbvz commented Nov 8, 2017

Locking this issue. Please see our documentation on solving this problem.

If you still have problems after following the steps in the docs, please open a new issue

lemanschik pushed a commit to code-oss-dev/code that referenced this issue Nov 25, 2022
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 javascript JavaScript support issues typescript Typescript support issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests