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

Created on 18 Apr 2017  ·  154Comments  ·  Source: microsoft/vscode

  • 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"
bug javascript typescript verified

Most helpful comment

I get this warning after I upgraded vscode to 1.12.1.

This didn't happen before.

I'm using nvm, the system is macOS Sierra 10.12.1

2017-05-08 08 54 18

All 154 comments

Can you please share the output from running:

$ which npm
$ npm --version

in your terminal

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.

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

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

however, I think its related to this issue https://github.com/Microsoft/vscode/issues/10876 and if I open from the CLI, the issue does not persist.

I've opened https://github.com/Microsoft/TypeScript/issues/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

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

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"}}

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

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

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

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

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

@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

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.

  • VSCode Version: Code - Insiders 1.12.0-insider (48ae6e3027be560d45dd1ebfbe090d6ff77af7f0, 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

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

Whooot 😱

@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.

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?

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

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: https://github.com/Microsoft/vscode/pull/24523, https://github.com/Microsoft/vscode/issues/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?

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

n added itself to my .bashrc, we should keep this setup working or a lot of people will have to update their bash configs.

It seems all the pull request achieved is that VSCODE_CLI is set and that lets us skip getUnixShellEnvironment() which launches process.env.SHELL as a login shell to extract the environment.

:+1: I'll revert

@DrkCoater Yours is a different case since you are on OSX. Could you double-check that when you launch VSCode from the dock then the warning message ("Could not install typings ...") shows and process.env['PATH'] has the path to nvm's node?

@chrmarti yes, I do have nvm's node in path, from my Code Insider's dev console:
process.env['PATH'];
"/Users/DrkCoater/bin:/Users/DrkCoater/.nvm/versions/node/v7.8.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"

But I don't have process.env['VSCODE_CLI'] set though. Not sure how to launch code insider from cli, as I have the non-insider version of code also installed also, the 'code' command will link to the regular one.

@DrkCoater Could you try running npm install types-registry from the terminal to see if that outputs any errors?

You can use code-insiders to launch the insiders build from the command line.

Assigning to @chrmarti and @Tyriar to asses if this is for april

Verified the fix for Linux. Unassigning milestone until we have a better understanding of the problem.

@chrmarti
I did npm install types-registry package installed to my project space, I'm still able to reproduce the warning message. I've restarted code insider fully a couple times still consistently seeing the warning message.

BTW, thanks for your tips, I had a chance to try out launching code insider from cli, I don't see the warning message launch from cli.

You can also try reboot your PC. Because when you update node via nvm, bash will show the latest version of the PATH, but VS Code will always get the previous version. You can check it with process.env['PATH']

Hi all, after the latest update I'm getting the warning

Could not install typings files for JavaScript language features. Please ensure that NPM is installed and is in your PATH

VSCode Version 1.12.1 (1.12.1)

nvm is in the path (both in .bashrc and .zshrc) and is visible when running process.env['PATH'] from Code's Dev Tools.

Mac was also rebooted a couple of times.

On my machine the command failed because I needed to configure a proxy for npm to use (npm config set proxy http://proxy:port --global). I noticed that NPM was actually running, but timing out after a while. The "please ensure that NPM is installed..." message was a red herring to me.

Same issue here after update to 1.12.1 (5 May 2017).
I do use NVM for my Node installations like others mentioned in this issue.

Current env:

// process.env.SHELL

'/bin/zsh'
// process.env.PATH

[ '/usr/local/bin',
  '/usr/local/sbin',
  '~/.nvm/versions/node/v6.10.1/bin',
  '/usr/local/bin',
  '/usr/bin',
  '/bin',
  '/usr/sbin',
  '/sbin',
  '/opt/X11/bin',
  '/Library/Frameworks/Mono.framework/Versions/Current/Commands',
  '/usr/local/sbin',
  '/Applications/Postgres.app/Contents/Versions/latest/bin',
  '/Users/giuseppe/.yarn/bin']

There doesn't appear to be a setting for me to specify the path, similar to how I specify the path to Node for eslint. E.g "eslint.nodePath": "C:/Users/User/AppData/Roaming/npm/node_modules"

@ryanbriscall npm is looked up on the PATH. If it is there, the problem must be different from what the message claims. @rjvdboon mentioned proxy settings were missing. Could that be the case with your setup too? Which OS and version VSCode are you on?

I can confirm I am having the same issue, with a very similar setup to @carusog above (yarn, nvm and zsh).

Does the problem persist if you launch code from the command line?

@chrmarti Thanks. I can confirm that my Windows Environment Variable "Path" contains "C:Users\User\AppData\Roamingnpm" -- So, I guess the problem is something else. And just to be clear, this is the "Path" variable for the User (me), not the "Path" variable for the System.

@chrmarti It does indeed work when launched from the command line

@chrmarti I also can confirm that starting code from command line works for me as well.
To be more explicit, I just moved to the folder and typed code . and it opened without the error.

A few items to investigate further based on this thread:

  • Continue discussion with TypeScript on this issue: Microsoft/TypeScript#15287 Is there a bug on the TS side around resolving npm based on the PATH? Should TS be smarter in trying to find a user's version of npm?

  • Should we add a setting to VSCode to allow users to explicitly specify their npm install path in order to better workaround cases like these?

  • Do we need npm at all? Could we ship a bundled version of npm for ATA? Ideally the implementation of automatic typings acquisition should be transparent to the user.

// cc @kieferrm @mhegazy @andy-ms

Upgraded today and am having the same issue as others. macOS using nvm and zsh. The problem didn't exist before this update. Two constant errors and one warning:

  • Cannot find flow (even though I have it and use it heavily)
  • Cannot find node in PATH (it is the first item in $PATH)
  • Could not install typings files for JavaScript language features. Please ensure that NPM is installed and is in your PATH. (It is)

Even though I am zsh, my .bashrc is also set as XCode launches with it during React Native compiles.

Having the same issue about Could not install typings files for JavaScript language features. Please ensure that NPM is installed and is in your PATH

This in on Windows 10 VSCode Stable

@mjbvz

Do we need npm at all? Could we ship a bundled version of npm for ATA? Ideally the implementation of automatic typings acquisition should be transparent to the user.

IMO, despite the smell of having multiple npm installations in one's workflow, I would say this is the better of the two approaches. While it's almost a given that a user will have some form of npm installed, one cannot make that assumption. This would also mitigate issues arising as a result of differing environments and configurations.

I'm having the

Could not install typings files for JavaScript language features. Please ensure that NPM is installed and is in your PATH

problem also.

I normally run VS Code from a Windows 10 standard user account. No matter how I launch VS Code from this account I get the Typings warning even though npm is available through my Path environment variable. However, if I launch a powershell session with Administrative privileges and run VS Code from the session, the warning does not appear. So I tried logging in to my Administrative account and found that the warning appears as long as VS Code is not run with Administrative privileges.

My conclusion is that the problem, at least for my situation, is one of access privileges. I have my npm global package directory in the $env:ALLUSERSPROFILE directory and VS Code installed in the $env:ProgramFiles(x86) directory.

__Update__:

I found that I had accidentally set my npm-cache directory to be inside the node install directory which requires Administrative privileges to write. When I moved the npm-cache directory to be in the $env:ALLUSERSPROFILE, the Typings warning disappeared. Also, I erroneously stated that the $env:ALLUSERSPROFILE directory requires Administrator privileges to modify; that is not true. Users have Write access to This folder and subfolders; and the CREATOR OWNER has Full control of Subfolders and files only.

I get this warning after I upgraded vscode to 1.12.1.

This didn't happen before.

I'm using nvm, the system is macOS Sierra 10.12.1

2017-05-08 08 54 18

I'm getting the same error:

image

This is on a Windows 10 system with Visual Studio Code v1.12.1:

image

Edit: sadly this is not a solution, it worked for me only a couple of times 😞

If you use the insider version on a mac with nvm try to quit the terminal _and_ vs code.

After that reopen both and in my case it was fixed, both from the command line and starting as normal application

the insider version is 1.13.0 and the commit is c615b43be67170e166779c9020a249442c4f36fc

it's worth a shot.

@zanza00 Didn't work for me. I still get the warning.

referencing #21655. We are getting somewhere over there. Seems to be with a timeout on the shell.

@simeonoff today the issue reappeared, sorry for the false hope :(

@joaomoreno Could #26438 be effecting mac users when we try to load the environment?

@mjbvz #26438 affects macOS and Linux only.

Same here. Arch Linux.
No warning when launching from terminal

@rendomnet how bizarre that launching from terminal "fixes" it for that instance.... At least there's a workaround for now.

Started getting this today after upgrading to VSCode 1.12.2, on macOS 10.12.3

Edit: Using nvm 0.31.0

@reaktivo I was hoping they would fix it in this release. The funny thing is I don't have this problem on my work machine, which is set up 1:1 with my personal computer. Same OS version, same VSCode version, same zsh, nvm, node version, npm version.

Same issue after updating to VSCode 1.12.2

Same issue here with 1.12.2
*
image
*

Same issue here.

Same issue after updating to VSCode 1.12.2

macOS 10.12.5
nvm 0.33.2
npm 4.6.1
zsh 5.2
Node 6.10.3
process.env['PATH'] = "/usr/local/sbin:/Users/eason/.nvm/versions/node/v6.10.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

See below.

From: Eason Kang [mailto:[email protected]]
Sent: Thursday, May 18, 2017 9:36 PM
To: Microsoft/vscode vscode@noreply.github.com
Cc: Salvatore Bianchi sjbianchi@gmail.com; Comment comment@noreply.github.com
Subject: Re: [Microsoft/vscode] Code Insider complains "Could not install typings files for JS/TS language features. Please ensure that NPM is installed" (#24961)

Same issue after updating to VSCode 1.12.2

macOS 10.12.5
nvm 0.33.2
npm 4.6.1
zsh 5.2
Node 6.10.3
process.env['PATH'] = "/usr/local/sbin:/Users/eason/.nvm/versions/node/v6.10.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"


You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/Microsoft/vscode/issues/24961#issuecomment-302585329 , or mute the thread https://github.com/notifications/unsubscribe-auth/ALZm5BmakElq0tonG-TENRw2Nx8fZ4wNks5r7PIHgaJpZM4NAmsA . https://github.com/notifications/beacon/ALZm5Lv3SEeS5FbldFgYkNdXDZNjqAxjks5r7PIHgaJpZM4NAmsA.gif

I've experienced this issue since about ~1 month now, and most recently this morning after updating to 1.12.2 on macOS 10.12.4, using nvm like many others (default node/npm combo is node 7.9.0 and npm 4.2.0, and npm is in my PATH as the first item, per what nvm does).

The notice appeared after Code was restarted automatically after updating to 1.12.2, but then went away after I quit Code and restarted it from the Dock.

Same here.
node 7.6.0
n 2.1.3
npm 4.1.2
vscode 1.12.2

Same here after upgrade VSCode to 1.12.2.

macOS 10.12.4
node 6.10.0
npm 3.10.10
nvm 0.33.0

Also running into this issue. A workaround for me it to vscode from the command line.

It's a bit funny but:
If app started via CLI, we got https://github.com/Microsoft/vscode/issues/24820. Workaround - start via dock.
if app started via dock icon, we are getting this one. Workaround - start via CLI :D

I don't have the NVM installed, but keep getting the same error too on VSCode 1.12.2
node 7.2.0
npm 3.10.9
OS X Sierra 10.12.3

osx + nvm user here. adding

  export NVM_DIR="$HOME/.nvm"
  . "/usr/local/opt/nvm/nvm.sh"

to ~/.zshrc resolved the problem for me. I'm going to change it to source ~/.bash_profile

cc @egamma

91c7fbe2421e679c69a4ce8c58711635a888f905 adds a new "typescript.npm" setting that allows you to explicitly tell VSCode/TypeScript where npm is installed on your machine. This does not have to point to the same version of npm you are using in a project, it only has to point to a valid npm install somewhere on your system. Try running which npm from the command line to get the path to your current npm

This new setting should be available in the next vscode insider build. It requires TypeScript 2.3.4 which will also be bundled in the next insiders. Please give it a try and let me know if you run into any issues with it

typescript.npm is hopefully only a short term workaround. The TypeScript team and I also discussed moving aware from using npm for automatic typings acquisition. I've opened https://github.com/Microsoft/TypeScript/issues/16159 to track this upstream

Hi,

I haven't had this problem before, but after updating to nodejs 8/npm5 this happen to me too. Not using NVM at all.

vscode: 1.12.2 and insider-versions until 2017/05/31
OS: Ubuntu 16.04 / i3WM

process.env['PATH'] contains the nodejs bin path, checkt with build in dev tools.

thank you @mjbvz for referencing the possible workaround, but it doesn't work from CLI with insider build from 2016/06/01.

usually i launch apps with rofi

@HammyHavoc What doesn't work? typescript.npm should bypass the path entirely and should not be effected by how you launch vscode

in my settings i point typescript.npm to my bin folder of my node installation. still getting the message. How is this connected to typescript at all? I'm using JS/JSX, no typescript.

@HerrVoennchen same here.. no typescript.. just simple JS/ES6 project class/function/variable intellisense.

@HerrVoennchen TypeScript powers our javascript intellisense. It is what is actually acquiring the typings files behind the scenes.

You should point typescript.npm to the full path to the npm executable:

"typescript.npm": "/Users/matb/.nvm/versions/node/v7.6.0/bin/npm"

Ok, that actually works, no message anymore, even on non-CLI launch.
Thougn the hint in the settings on typescript.npm should be corrected. it says

// Specifies the path to the NPM install used for automatic typings acquisition. Requires TypeScript >= 2.3.4

which at least I think of the path excluding the executable.

Edit: And this is reasonable since the path in the env variable is also without the executable

Updated setting description to explicitly state this should point to the executable: 148a23aef5135ae3b0e8a380fc4804f84d58933e

Im still getting this to occur on latest insiders f977399d58f7b64db35047fafe0c6e59e15f11d5

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 set "typescript.npm": "/usr/local/bin/npm" and Im using Node 8 with the n node manager. My binaries are in the standard locations.

Launching with the CLI will surprise this warning, as noted above in the issue.

@wprater This works for me with npm 5.0.0 on Ubuntu. Please check which version of TypeScript you are using, this requires TypeScript 2.3.4.

@wprater This works for me with npm 5.0.0 on Ubuntu. Please check which version of TypeScript you are using, this requires TypeScript 2.3.4.

installed the latest typescript and the issue persists.

⟩ yarn global add typescript

⟩ tsc --version
Version 2.3.4

⟩ which tsc
/usr/local/bin/tsc

⟩ which node
/usr/local/bin/node

⟩ node --version
v8.0.0

⟩ which npm
/usr/local/bin/npm

⟩ which yarn
/Users/wprater/.yarn/bin/yarn

@wprater Just to be sure: Also check the typescript version installed in node_modules if there is one and select 2.3.4 with the Select TypeScript Version command from the command palette (Ctrl + Shift + P).

Same problem here with vscode 1.12.2

@wprater Any update on that? (See previous question.)

@wprater Just to be sure: Also check the typescript version installed in node_modules if there is one and select 2.3.4 with the Select TypeScript Version command from the command palette (Ctrl + Shift + P).

@chrmarti Its already set to 2.3.4 when I issue that command.

image

@wprater If you don't see typescript.npm working in the current insiders build, please open a new issue. Please also try collecting the typings installer logs so that we can understand what may be going wrong:

  1. Set "typescript.tsserver.log": "verbose"
  2. Restart VSCode and reproduce the npm not found issue
  3. Run the Open TSServer log File command and share the ti-xxx.log file

Thanks

@mjbvz If one wants to use vscode with WSL will it be possible to set typescript.npm to redirect to bash -ic npm. I'm using the bash terminal and I'd to sandbox my node development to linux as much as posible.

Unfortunately, after setting "typescript.npm": "/usr/local/n/versions/node/7.10.0/bin/npm", upgrade typescript to 2.3.4 and select 2.3.4 version in vscode command.
This issue still exists.

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

Both conditions are true for my setup, but it is still giving the issue/warning. i.e. I do have npm installed and have also set "typescript.npm" to point to the fullpath of the npm executable ("/usr/bin/npm").

_~$ which npm --> /usr/bin/npm_

TSServer Log messages snippet:
NPM location: "/usr/bin/npm" (explicit '--npmLocation' provided)
Npm config file: /home/obi/.cache/typescript/package.json
Updating types-registry npm package...
Error updating types-registry package: Command failed: "/usr/bin/npm" install types-registry
Sending response: {"kind":"event::initializationFailed","message":"Command failed: \"/usr/bin/npm\" install types-registry"}
Response has been sent.
...
[Trace - 9:53:44 PM] Event received: typesInstallerInitializationFailed (0).

(See full log file attached - filename: ti-2232.txt)

Environment:
OS: Ubuntu Linux 16.04
VSCode version: 1.13.0
Node.JS version: 7.10.0
Typescript version: 2.3.4
ti-2232.txt

Seeing the same here if I open anywhere except via the code cli. Same message (could not install typings files for JavaScript language features.".

Environment:
OS: Mac OS 10.12.5
VSCode version: 1.13.1
Node version: 7.9.0
Shell: fish 2.5.0

Path in my terminal: /Users/<username>/Work/go/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin /usr/local/share/dotnet:/usr/local/MacGPG2/bin:/Users/<username>/Work/go/bin

Path in VSCode developer tools: /usr/bin:/bin:/usr/sbin:/sbin.

I'm not sure if this would help anyone, but I fixed this by adding nvm to ~/.bash_profile. I believe the default shell is bash and I'm using zsh so my nvm path is missing in profile.

wait for next vscode insider build ..

This is happening on 1.13.1, here's the relevant error from the TS Server Log:

Info 39   Received response: {"kind":"event::initializationFailed","message":"Command failed: \"/Users/whitten/.nvm/versions/node/v8.1.2/bin/npm\" install types-registry"}
Info 40   event: {"seq":0,"type":"event","event":"typesInstallerInitializationFailed","body":{"message":"Command failed: \"/Users/whitten/.nvm/versions/node/v8.1.2/bin/npm\" install types-registry"}}
Info 41   Received response: {"projectName":"/dev/null/inferredProject1*","typeAcquisition":{"enable":true,"include":[],"exclude":[]},"compilerOptions":{"module":1,"target":2,"allowSyntheticDefaultImports":true,"allowNonTsExtensions":true,"allowJs":true,"jsx":1,"checkJs":true,"noEmitForJsFiles":true,"maxNodeModuleJsDepth":2},"typings":["/Users/whitten/Library/Caches/typescript/node_modules/@types/react/index.d.ts","/Users/whitten/Library/Caches/typescript/node_modules/@types/node/index.d.ts"],"unresolvedImports":["child_process","crypto","crypto","events","http","net","readline","stream","stream","tls"],"kind":"action::set"}

That instance of npm does in fact exist and is executable by my user:

$ which npm
/Users/whitten/.nvm/versions/node/v8.1.2/bin/npm

$ npm --version
5.0.3

@bwhitty I reproduced it when there is no working folder, and the error disappears when there is a working folder. Hope this would help.

Info 100  Sending request: {"projectName":"/dev/null/inferredProject1*","fileNames":["c:/Users/Lulus/bin/vscode/resources/app/extensions/node_modules/typescript/lib/lib.es6.d.ts","walkThroughSnippet:/c%3A/Users/Lulus/bin/vscode/resources/app/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#1.js","walkThroughSnippet:/c%3A/Users/Lulus/bin/vscode/resources/app/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#3.js","walkThroughSnippet:/c%3A/Users/Lulus/bin/vscode/resources/app/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#7.js","walkThroughSnippet:/c%3A/Users/Lulus/bin/vscode/resources/app/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#6.js","walkThroughSnippet:/c%3A/Users/Lulus/bin/vscode/resources/app/out/vs/workbench/parts/welcome/walkThrough/electron-browser/editor/vs_code_editor_walkthrough.md#4.js"],"compilerOptions":{"module":1,"target":2,"allowSyntheticDefaultImports":true,"allowNonTsExtensions":true,"allowJs":true,"jsx":1,"checkJs":false,"maxNodeModuleJsDepth":2,"noEmitForJsFiles":true},"typeAcquisition":{"enable":true,"include":[],"exclude":[]},"unresolvedImports":["child_process","crypto","events","http","http","net","readline","stream","tls","url"],"projectRootPath":"","kind":"discover"}
Info 101  Received response: {"projectName":"/dev/null/inferredProject1*","typeAcquisition":{"enable":true,"include":[],"exclude":[]},"compilerOptions":{"module":1,"target":2,"allowSyntheticDefaultImports":true,"allowNonTsExtensions":true,"allowJs":true,"jsx":1,"checkJs":false,"maxNodeModuleJsDepth":2,"noEmitForJsFiles":true},"typings":["C:/Users/Lulus/AppData/Local/Microsoft/TypeScript/2.4/node_modules/@types/node/index.d.ts"],"unresolvedImports":["child_process","crypto","events","http","http","net","readline","stream","tls","url"],"kind":"action::set"}

Note the "projectName":"/dev/null/inferredProject1*" section. However I'm using windows 10.

@bwhitty Try explicitly setting typescript.npm as described here: https://code.visualstudio.com/Docs/languages/javascript#_fixing-npm-not-installed-warning-for-automatic-type-acquisition

Im still having issues on every inside build with npm in /usr/local/bin, even with the setting set to such

@mjbvz the error happens with that setting explicitly set to the path from the which npm command above.

Same problem here.
Windows 10
VS Code 1.13.1
Node v6.11.0
TypeScript v2.3.4.

Looks like npm is found, but the typings install is still failing. Can you please collect the typings installer logs and open new issue so that I can investigate.

To collect the typings installer log:

  1. Set "typescript.tsserver.log": "verbose"
  2. Restart VSCode
  3. Reproduce the issue.
  4. Run the TypeScript: Open TS Server log command
  5. This should open a folder with two files: tsserver.log and ti-xxx.log file.

Please share the ti-xxx.log file which has information about automatic typings acquisition

I'm still having this problem with or without typescript.npm set.
With typescript.npm set I get this in TS server log
[Trace - 2:52:39 PM] Event received: typesInstallerInitializationFailed (0).
Data: {
"message": "Command failed: \"/Users/estebanc/.nvm/versions/node/v4.5.0/bin/npm\" install types-registry"
}

For those having issues, I'm not on the VSCode team, but the first insider build fixed this for me, with this workaround.

I had set the path to use ~ but that didn't work. And setting it to nvm's location for npm woudn't work, as the different projects I work with have different node versions, so I can't just pick one, and I can't use nvm's default location as that would just use the currently selected node version that may not have been initialised yet and which would be incorrect for the different projects.

My workaround was creating a /Users/balupton/bin/npm script that contains:

#!/usr/bin/env bash -l
if ! which npm; then
   nvm use
fi
npm "$@"

Then setting my typescript.npm value to point to that file. Remember to chmod +x /Users/balupton/bin/npm as well.

You could probably change its source to:

#!/usr/bin/env bash

# NVM
if is_dir "$HOME/.nvm"; then
    export NVM_DIR="$HOME/.nvm"
    # shellcheck disable=SC1090
    source "$NVM_DIR/nvm.sh"
fi

# NPM
if ! which npm; then
   nvm use
fi
npm "$@"

that way it won't load your login shell and just load nvm, but I haven't tried that.

@mjbvz I got this:

Error updating types-registry package: Command failed: "/Users/Hunter/.nvm/versions/node/v7.9.0/bin/npm" install types-registry
Sending response: {"kind":"event::initializationFailed","message":"Command failed: \"/Users/Hunter/.nvm/versions/node/v7.9.0/bin/npm\" install types-registry"}
Response has been sent.

Still have the problem with new version 1.14.0

Still nothing

  • VS code 1.14.2 (doesn't work with latest insiders either - 1.15.0-insider)
  • Typescript 2.4.2
  • OS kubuntu, fish shell
NPM location: "/home/daniel/n/bin/npm" (explicit '--npmLocation'  provided)
Npm config file: /home/daniel/.cache/typescript/2.4/package.json
Updating types-registry npm package...
Error updating types-registry package: Command failed: "/home/daniel/n/bin/npm" install types-registry
Types registry file '/home/daniel/.cache/typescript/2.4/node_modules/types-registry/index.json' does not exist
Sending response: {"kind":"event::initializationFailed","message":"Command failed: \"/home/daniel/n/bin/npm\" install types-registry"}
Response has been sent.

Some notes:

  1. If I try to manually run the same failing command from console: "/home/daniel/n/bin/npm" install types-registry, it works fine
  2. Referenced file (/home/daniel/.cache/typescript/2.4/package.json) is empty (content is {})
  3. Types registry file '/home/daniel/.cache/typescript/2.4/node_modules/types-registry/index.json' does not exist. There is no node_modules under /home/daniel/.cache/typescript/2.4/ - the only file there is an empty package.json
  4. If I start code from console, it works:
NPM location: "/home/daniel/n/bin/npm" (explicit '--npmLocation'  provided)
Npm config file: /home/daniel/.cache/typescript/2.4/package.json
Updating types-registry npm package...
Updated types-registry npm package

Could it be that it doesn't use the proxy setting correctly? (I have a corporate proxy set in VScode settings and in $HTTP_PROXY)

Still have the problem with new version 1.14.0
👍 14

Same here.. pretty simple install. Node is in /usr/local/bin and unless I launch from CLI, the PATH is not correct.

The problem is still with new version 1.14.2, so this issue should be opened, right? @mjbvz

I have the same problem. typescript.npm is pointing to nvm's npm executable. Still seeing the warning.

I am also having this issue in 1.14.2 on Mac OS.

Sadly it still does not work, but I found a nice workaround:

  sudo ln -s $(which npm) /usr/bin/npm
  sudo ln -s $(which node) /usr/bin/node

Happy coding guys :+1:

@FieryCod got error: ln: /usr/bin/npm: Operation not permitted

Either you did not type sudo or you've typed your password incorrectly.

@FieryCod I'm pretty sure that I run this command correctly, but still got error. Is it a problem with my macOS?

As I can see macOS has usr/sbin not usr/bin

sudo ln -s $(which npm) /usr/sbin/npm
sudo ln -s $(which node) /usr/sbin/node

Or

ln -s $(which npm) /usr/sbin/npm
ln -s $(which node) /usr/sbin/node

Seeing this in VSCode Version 1.14.2
Commit cb82febafda0c8c199b9201ad274e25d9a76874e

OS: Ubuntu 16.04
Typescript 2.4

If I open via CLI it works fine. But not if I open Code from the taskbar.

The process.env["PATH"] values are different depending on how i open it. NVM is only in the path when I open via CLI

CLI:
"/home/akosua/.rbenv/plugins/ruby-build/bin:/home/akosua/.rbenv/shims:/home/akosua/.rbenv/bin:/home/akosua/bin:/home/akosua/anaconda3/bin:/home/akosua/.nvm/versions/node/v7.6.0/bin:/home/akosua/.pyenv/shims:/home/akosua/.pyenv/bin:/home/akosua/.pyenv/shims:/home/akosua/.pyenv/bin:/home/akosua/bin:/home/akosua/.local/bin:/opt/OpenPrinting-Gutenprint/sbin:/opt/OpenPrinting-Gutenprint/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

Taskbar
"/opt/OpenPrinting-Gutenprint/sbin:/opt/OpenPrinting-Gutenprint/bin:/home/akosua/bin:/home/akosua/.local/bin:/opt/OpenPrinting-Gutenprint/sbin:/opt/OpenPrinting-Gutenprint/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin"

Could this please be reopened? The issue is certainly still there.

Did you set "typescript.npm": https://code.visualstudio.com/Docs/languages/javascript#_fixing-npm-not-installed-warning-for-automatic-type-acquisition This requires TypeScript 2.3.4+ so if you are using a custom typescript.tsdk setting, make sure you are pointing to a newer TS version

@mjbvz "typescript.npm" setting didn't work for me or for many people

[Trace - 2:52:39 PM] Event received: typesInstallerInitializationFailed (0).
Data: {
"message": "Command failed: "/Users/estebanc/.nvm/versions/node/v4.5.0/bin/npm" install types-registry"
}

@chanep Do you have a proxy configured? If so, could try starting VSCode from the command line and check if it works? (Could be #31336.)

Im not behind a proxy, but still exhibit this behavior and it extends through the shell-format package, which complains about not being able to find shfmt in my path, unless I launch with cli, then all is good.

@wprater That sounds like #21655.

I had this problem after updating to Node 8/NPM 5 with NVM. Was able to fix by setting typescript.npm to point to the NVM version of Node 7/NPM 4:

    "typescript.npm": "/Users/[ ... ]/.nvm/versions/node/v7.10.1/bin/npm"

Seems the VS Code typing mechanism is incompatible with Node 8/NPM 5?

I have never been able to resolve this issue.

Imgur

"typescript.npm": "/Users/mherold/.nvm/versions/node/v6.11.0/bin/npm"

process.env['PATH']
"/Users/mherold/.avn/bin:/Users/mherold/.nvm/versions/node/v6.11.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS:/Users/mherold/.rvm/bin:/Users/mherold/.rvm/bin:/Users/mherold/.nvm/versions/node/v6.11.0/bin"

P.S. Hey @bbarwick-fdg 💃

Same problem, MacOS 10.12, VSC 1.15.1…

Hello,

I had the same problem: working on CLI, but not on the taskbar.
I think the reason is that from the taskbar it does not source the rc file I use on console startup, where I prepend node path to my $PATH.
So I resolved prepending the path to node to the code command that was set on the icon launcher.
I changed the command from this:
/usr/bin/code %f
to this:
PATH="$HOME/.node/current/bin:$PATH" /usr/bin/code %f

And now it does not complain anymore.

Yes with some finagling, following @lucamartini 's steps above seem to have worked for me as well

Experiencing the same problem on a new MBP with MacOS 10.12.6 VSC 1.15.1 and 1.16.0-insider. Doesn't matter if I start from terminal or not. process.env.PATH includes the path to my npm, typescript.npm points to the correct npm. Have also tried to link my /usr/local/bin/npm to /usr/bin/npm and /usr/sbin/npm with no success.

npm install types-registry works just fine outside of VSC.

The error I'm seeing:
{"kind":"event::initializationFailed","message":"Command failed: \"/usr/sbin/npm\" install types-registry"}

@bernljung What are the permissions on /usr/sbin/npm? Are you running as root?

@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.

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

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)

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

Thanks @viktor-wolf! I've opened https://github.com/Microsoft/TypeScript/issues/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

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"

@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.

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

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.

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

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

I upgraded typescript to 2.5.3 and am still seeing this.

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.

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

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.

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

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
f6ef4bef42fa2948426c99fefa340235e67a0c5e

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,

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

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

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

@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

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrkiley picture mrkiley  ·  3Comments

omidgolparvar picture omidgolparvar  ·  3Comments

VitorLuizC picture VitorLuizC  ·  3Comments

biij5698 picture biij5698  ·  3Comments

philipgiuliani picture philipgiuliani  ·  3Comments