Error npm install Angularjs-dragula

Asked

Viewed 112 times

1

I need to install the

Angularjs-dragula ng2-dragula React-dragula

At first I made the mistake:

C:\Users\email\Desktop\Parafernalia Test> npm install angular js-dragula --save
  npm WARN saveError ENOENT: no such file or directory, open 'C:\User\email\package.jason'
  npm notice created a lockfile as package-lock.json. You should commit this file.
  npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\email\package.json'
  npm WARN email No description
  npm WARN email No repository field.
  npm WARN email No README data
  npm WARN email No license field.

[email protected] Added 7 Packages from 3 Contributors and audited 8 Packages in 24.066s

I created the file in the project folder - package.json

I passed the command again and the error now is:

C:\Users\email\Desktop\Parafernalia Teste>npm install angularjs-dragula --save
  npm ERR! file C:\Users\email\Desktop\Parafernalia Test\package.json
  npm ERR! code EJSONPARSE
  npm ERR! JSON.parse Failed to parse json
  npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
  npm ERR! JSON.parse Failed to parse package.json data.
  npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

  npm ERR! A complete log of this run can be found in
  npm ERR!     C:\Users\email\AppData\Roaming\npm-cache\_logs\2018-07-05T13_59_46_328Z-debug.log

This same error occurs when I try the command to install React-dragula

My package.json file is empty.

Can someone help me?

PS.: Dragula is a js library for Dnd https://github.com/bevacqua/dragula

  • Please add your own package.json to the question, and replace the images with the text format error.

  • I switched images to text format. and my file package.json has no content yet.

1 answer

2


The error occurs because the files .json were created manually without a valid structure.

When the command npm install angularjs-dragula --save is executed, occurs the parse of the contents of the archive package.json, however as it is empty the following error is returned:

npm ERR! JSON.parse Falied to parse json

Notice that one of the lines says the following:

npm ERR! JSON.parse package.json must be actual JSON

That is, the content of package.json should be a valid json.

Once the argument --save is used, dependency is saved in the package.json, at the knot dependencies:

//...
"dependencies": {
    "angularjs-dragula": "^2.0.0"
}
//...

Like the file package.json was created without content and parse failed, the npm cannot save the dependency.

How to solve the problem?

Like the file package.json is empty, just delete it and run the command in the terminal inside the project folder. The command will create the file package.json automatically:

npm init

After answering some questions in the terminal, note that now the package.json was generated with an initial structure containing a valid json, however the "dependencies" node does not exist, since no dependency has been added to the project.

To add the dependency, run the command:

npm install angularjs-dragula --save

Note that the node now exists and the dependency has been successfully added to the project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.