forcedotcom / salesforcedx-vscode

Salesforce Extensions for VS Code
https://developer.salesforce.com/tools/vscode
BSD 3-Clause "New" or "Revised" License
947 stars 405 forks source link

`force:project:create`command returns "ERR_ASSERTION: A name parameter is required to create a storage" #253

Closed neildaemond closed 6 years ago

neildaemond commented 6 years ago

Summary

ERR_ASSERTION: A name parameter is required to create a storage error message when using SFDX:Create Project

Steps To Reproduce:

  1. install java via https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
  2. Install SFDX CLI and salesforcedx-vscode into vscode
  3. run use SFDX: create project
  4. observe "ERR_ASSERTION: A name parameter is required to create a storage" in bottom console.

Note: running sfdx force:project:create --projectname testing --outputdir /home/neil/playground/salesforce/test in command line gives same error

Expected result

SFDX project should be created

Actual result

Error message in terminal: ERR_ASSERTION: A name parameter is required to create a storage

Additional information

VS Code Version:

Version 1.19.2 Commit 490ef761b76b3f3b3832eff7a588aac891e5fe80 Date 2018-01-10T15:57:21.071Z Shell 1.7.9 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64

SFDX CLI Version: sfdx-cli/6.0.26-3d23012 (linux-x64) node-v8.6.0

OS and version: Ubuntu 16.04

Java version: : java version "1.8.0_151" Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

Internal Work Item: W-4241831

vazexqi commented 6 years ago

@neildaemond - Thanks for filing this.

I suspect I know what the root cause is. Could you confirm if you have a package.json (without a "name" field) somewhere in the folder or in one of its ancestors?

We are tracking this internally as W-4241831 and our repro steps are:

  1. Create top level directory (test)
  2. cd into test
  3. touch package.json (this creates an empty package.json without any entries)
  4. run sfdx force:apex:class:create -n testclass (we repro this with force:apex:class:create but this will also affect sfdx force:project:create)
neildaemond commented 6 years ago

adding package.json with the contents

{
    "name": "<anything>"
}

Seems to allow it to work without the Mentioned Error (Although I have no Idea how that package.json should be written otherwise). Thanks!

angelsalazar-zz commented 6 years ago

Any updates, this issue is still happening on sfdx version sfdx-cli/6.15.0-ded9afdffb (darwin-x64) node-v8.9.4

vazexqi commented 6 years ago

@angelsalazar - Do you have a top-level and malformed package.json (a package.json without "name" is it) somewhere in your current folder's ancestor?

angelsalazar-zz commented 6 years ago

@vazexqi Weird, there was one package.json file without a name attribute in the root folder of the system directory, I deleted and the command run as expected.

Woody88 commented 6 years ago

Hi everyone, I would like to confirm (just for the next person :) ) that I was getting the same error and after seeing @angelsalazar 's comment I decided to check the root of my system and noticed that I had a random package.json file. I deleted it and everything worked fine.

ntotten commented 6 years ago

Thanks for the update!

miteshmsharma commented 5 years ago

This is very weird and was happening to all my directories because guess what there was a package.json in my c drive. I am baffled as to what is the cause of this error. Its not even like we can't create more components in a bundle which is packaged already. any clue experts whats going on here... I a noob to know the intricacies but this was reported a year back and here I am experiencing this same behavior. What gives?

miteshmsharma commented 5 years ago

The error screen attached image

jduelfer commented 5 years ago

@miteshmsharma it seems to just be a requirement of npm: https://docs.npmjs.com/files/package.json.html. I just got the same error all of a sudden after I added a set of Jest tests for LWC. @neildaemond's suggestion removes the error, but I am not exactly sure why sfdx requires the name attribute. I personally just added "name": "sfdx-company" to my package.json and it works fine. Also curious why this is needed at a higher level though.

WadeLovell commented 4 years ago

To be clear, you do not have to search through the tens of package.json files on your computer looking for one without a name parameter. Instead, create a new file with the following contents: { "name": "sfdx-company" } and save it in your new project directory.

PackageDotJsonCreated

sloughin commented 4 years ago

It would be REALLY helpful to include a note about this issue in the instructions in the following Trailhead training module:

https://trailhead.salesforce.com/content/learn/projects/quickstart-vscode-salesforce/use-vscode-for-salesforce

because it seems highly likely that students may have played around with node and have random package.json files somewhere their directory hierarchy, and then when they try to follow the instructions, they get this really misleading error about not supplying a project name, when of course they actually did supply one!! Thanks!

Nykollas commented 4 years ago

I'm facing this error again with salesforce VSCcode extensions v49.7

ar-srinivas commented 3 years ago

We are facing this error again on 7.83 with salesforcedx 50.9.1. The error details: ERROR running force:project:create: A name parameter is required to create a storage

dx #sfdx

adal877 commented 2 years ago

For any one having this problem, look into your ~/, there's probably a package.json with the sfdx plugins but no "name". So you can just insert this line right after the first {: "name": "sfdx". Final result might look like this:

{ "name": "sfdx", "dependecies": { plugins here... } }

sfdx --version : sfdx-cli/7.132.0 linux-x64 node-v16.13.2

thomasheuberger commented 2 years ago

Thanks, that did the trick.

For any one having this problem, look into your ~/, there's probably a package.json with the sfdx plugins but no "name". So you can just insert this line right after the first {: "name": "sfdx". Final result might look like this:

{ "name": "sfdx", "dependecies": { plugins here... } }

sfdx --version : sfdx-cli/7.132.0 linux-x64 node-v16.13.2