Unexpectedly, the task of "AssignTargetPath" did not complete successfully

While working on my Node project using Node Tools for Visual Studio (version 1.1), I encountered this error unexpectedly. I was using Visual Studio Community Edition 2015 and had the latest version of Typescript (v1.7.6) installed.

Error:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Node.js Tools\Microsoft.NodejsTools.targets(119,5): error MSB4018: The "AssignTargetPath" task failed unexpectedly.
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
at Microsoft.Build.Tasks.AssignTargetPath.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Done building project "BuyCo.njsproj" -- FAILED.

Build FAILED.

Upon researching online, it appears that the issue may be related to the MAXPATH problem with Node/npm.

Answer №1

After some searching, a friend recommended that I switch from npm 2 to npm 3. Here are some details to help others avoid the hassle of searching through various online forums:

The problem I encountered was related to the Windows MaxPath issue. I was able to resolve it by

  • upgrading from npm 2 to npm 3. Windows users can find more information here.
  • deleting all npm packages in my project with the command rm -r node_modules
  • reinstalling them with npm install.

In npm 3, they made improvements to have flatter folder structures. However, it is worth noting that npm 3 is still in beta and for stability and migration, it is recommended to wait for npm 4. I personally found success with npm 3.

It's worth mentioning that I was using git bash. I noticed that the npm version in git bash was still at v2, while it was already v3 in a regular command prompt like cmd. In bash, you can confirm if you are experiencing the MAXPATH issue with this command:

(find | awk '{ print length(), NR, $0 | "sort -rn" }' | less)

When you run this command, you will enter the (less) editor. Look at the first column/number as the lines are sorted by length. The length should be below 260. Exit the editor with :q. Keep in mind that you need to include the base path length yourself, as the length shown is within the current folder. Perhaps a bash expert could suggest a better command.

Answer №2

Whenever I encounter a recurring problem in VS 2019, I find that closing and reopening the program usually resolves the issue temporarily. This allows me to continue working on my project until the problem resurfaces, prompting me to repeat the process. If you're experiencing the same issue, it's possible that VS is just being finicky. It may be wise to restart the program before attempting any drastic solutions.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the reason behind the node_modules folder being marked as read-only by VS 2017 in a .Net Core App?

I recently ran into an issue with my .Net Core application that uses Angular for client-side code. The default template in VS 2017 seemed to be causing my node_modules folder to become read-only. Previously, I could install packages using the command line ...

Testing with mount in React Enzyme, the setState method does not function correctly

I've been experimenting with testing this code block in my React App using Jest and Enzyme: openDeleteUserModal = ({ row }: { row: IUser | null }): any => ( event: React.SyntheticEvent ): void => { if (event) event.preventDefault(); ...

`Typescript does not adhere to the specified type when used inside a for loop with a local

This code snippet declares a variable venuelist of type Venue array and initializes it as an empty array. The type Venue has a property named neighborhood. There is a for loop that iterates through the venuelist array and checks if the neighborhoods matc ...

Ways to display the ping of a game server on your screen

Is there a way to display the game server's ping on the screen like in the example below? this.tfEnter.text = ShowPing + " ms"; Sometimes the code snippets provided in examples may not function properly. Channel List Image: https://i.stack ...

Deactivate the rows within an Office UI Fabric React DetailsList

I've been attempting to selectively disable mouse click events on specific rows within an OUIF DetailsList, but I'm facing some challenges. I initially tried overriding the onRenderRow function and setting CheckboxVisibility to none, but the row ...

What is the best way to implement bypassSecurityTrustResourceUrl for all elements within an array?

My challenge is dealing with an array of Google Map Embed API URLs. As I iterate over each item, I need to bind them to the source of an iFrame. I have a solution in mind: constructor(private sanitizer: DomSanitizationService) { this.url = sanitizer. ...

An array variable marked as mat-checked contains the total sum

Currently, I am utilizing mat-checked to calculate a total sum from an Array. The issue arises when the number of items in my array varies, triggering an error: ERROR TypeError: Cannot read property 'isChecked' of undefined Is there a way to ...

The latest version of Angular (7.0.5) introduces a new feature where the ng new command no longer prompts the user with the question "Would

I'm looking for assistance in figuring out why I am unable to create a new project using the latest version of Angular 7. Desired outcome: ng new firebase-auth ? Would you like to add Angular routing? No ? Which stylesheet format would you like to u ...

Every time I try to use NPM install, I keep encountering issues with JSON parsing errors and unable to locate files in the

I'm encountering issues with npm install: Getting JSON parse exceptions (at random locations each time) Receiving "file not found in .staging" warnings My current environment is as follows: Node: 12.18.3, Npm: 6.14.6 This works fine for my other t ...

Switching slides in Ionic 4 with a simple button click

I want to switch slides by clicking a button on my presentation. Here is an example code snippet: <ion-slides> <ion-slide> Slide one <ion-slide> <ion-slide> Slide Two <ion-slide> </ion-slides> <butt ...

There was a problem uploading the Feed document using amazon-sp-api: Invalid initialization vector encountered

I'm encountering an issue while attempting to upload a Feed document to Amazon using the createFeedDocument operation of the Selling Partner API. Following the API call, I received a response object that includes the feedDocumentId, url, and encryptio ...

What could be the reason for receiving an undefined user ID when trying to pass it through my URL?

Currently, I am in the process of constructing a profile page and aiming to display authenticated user data on it. The API call functions correctly with the user's ID, and manually entering the ID into the URL on the front end also works. However, wh ...

When attempting to access the Next.js 13.5.0 package via the npm registry, the resource was not found

click here to view image error message: The file 'next@https://registry.npmjs.org/next/-/next-13.5.0.tgz' is not found in this registry. An issue has arisen during the deployment on Vercel. It was functioning properly just a short while ago, wi ...

What is the best way to conduct tests on this React component using Jest?

I'm currently working on increasing the test coverage for a wrapper component in my codebase using jest. Although I haven't been able to identify any specific usage of this component, it's important to ensure that it is covered by tests. M ...

When using Angular's .navigateByUrl() method, it successfully navigates to the desired page, however the html content is not

Whenever I try to navigate to the home page after logging in, I encounter an issue. I have a navbar <app-header></app-header> with two links - one for signing up and another for logging in. After successfully logging in, my goal is to navigate ...

Encountering issues with the command npm install --save web-animations-js, the

Issue encountered while trying to run "npm install --save web-animations-js". It seems like the request to https://registry.npmjs.org/web-animations-js failed due to a mismatch in the Hostname/IP in the certificate. The error message indicates that the Hos ...

Zod combinator that accepts a dynamic field name

When converting XML to JSON, my library outputs {MyKey: T} for single-element lists and {MyKey: T[]} for multi-element lists. The equivalent TypeScript type is type XmlJsonArray<T, element extends string> = Record<element, T | T[]>. To implemen ...

Showing container element only if certain condition is met but display the children in Angular 2+

I am looking to create a grid-style view for a list of Angular components, where I can display up to 4 components in each row. The question that comes close to what I need is the following: Angular 2 NgIf, dont render container element on condition but sh ...

Connecting the SelectedItem of a listbox in ngPrime to an Observable Collection in Angular2

I am facing an issue while trying to use the ngPrime listbox in Angular2. I have a scenario where I am fetching an array of objects from Firebase as an observable and attempting to display it correctly in the listbox. <div *ngIf="addContactDialogVisibl ...

How come webstorm/react-hook-forms isn't showing me suggested choices for the "name" field?

I'm looking to create components with inputs, but I'm currently facing an issue with tooltips not showing for the name. I would like the form fields to display the name. export const Form: FormType = ({ children, form }) => ( <FormProvide ...