Visual Studio 2017 External Tools npm Not working

前端 未结 6 1768
猫巷女王i
猫巷女王i 2021-01-14 15:23

I have a typescript project that requires npm 3+. I\'ve install it to C:\\Program Files\\nodesjs, and I set my system environment variables to point there.

In vis

相关标签:
6条回答
  • 2021-01-14 15:36

    The way you add an extra path to the external tools seems correct. Are you sure you have the correct version there ? (On my installation the built-in nodejs version was 5.4.1 and npm verison 3.3.4)

    To be sure, for me the best way to figure out which npm installation Visual Studio 2017 was using is this (taken from How to get the npm global path prefix) :

    PM> npm config get prefix
    

    And if all else fails, you can always update the built-in npm too. Just navigate to your web external path (probably C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External) and :

    pm> npm install npm@latest
    
    0 讨论(0)
  • 2021-01-14 15:37

    I had a similar issue when trying to use Task Runner Explorer with webpack. My issue was that my webpack.config.js file was not in the root of my project (it was in my scripts folder). Moving it to the root did the trick for me.

    0 讨论(0)
  • 2021-01-14 15:50

    For your Node installation folder, I'm assuming you meant:

    C:\Program Files\nodejs NOT
    C:\Program Files\nodesjs

    Also, you're testing the npm version from the Package Manager Console. I'm not sure that respects your external tools configuration (but rather a Powershell Profile) so the result there may not change.

    Instead, with your project open, you should be able to right-click on the npm node under Dependencies in Solution Explorer and select Restore Packages. In your Output window (Bower/npm), you should see the npm install command being executed from your machine-wide Node installation:

    "C:\Program Files\nodejs\npm.CMD" install

    0 讨论(0)
  • 2021-01-14 15:53

    The external web tools configuration is only used when building. The PATH variable is (re-)set using the $(ExternalToolsPath) parameter by one of the build tasks which is: a semi-colon concatenated value of the external web tools list.

    Since you are running the command in the PowerShell Console window, your external web tools configuration is not used.

    My best assumption is that you've got multiple directories in your PATH environment variable that has the npm executable. The latest directory will always win. If this is the case, either remove the duplicate ones or make sure that the directory where your latest version of npm is added last. You can do this from the system properties or from the Nuget profile used by the PowerShell Console window.

    To check your PATH variable in PowerShell use: Write-Host $ENV:Path

    To list the possible locations of the npm executable from PowerShell use: cmd /c where npm

    0 讨论(0)
  • 2021-01-14 15:54

    Right click on My Computer then Click on Properties then click on Advance System Setting environmental variable-> system variable-> select Path then click on Edit button add %AppData%\npm %ProgramFiles%nodejs\ C:\Program Files\nodejs

    then click ok->ok->ok->ok

    enter image description here

    once completed this process . close and open again visual studio and excute command " nmp start " in visual studio terminal.

    0 讨论(0)
  • 2021-01-14 15:56

    This happened to me after deleting the "dist" folder from a dotnet new angular template project. (npm is installed and in the path)

    Recreating the "dist" folder (under ClientApp) from inside Visual Studio 2017 solved the issue for me.

    0 讨论(0)
提交回复
热议问题