Error npm install angularjs-dragula

1

I need to install

angularjs-dragula ng2-dragula react-dragula

At first I had the error:

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 ran 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\_logs18-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 anyone help me?

PS: Dragula is a js library for DnD link

    
asked by anonymous 05.07.2018 / 16:10

1 answer

2

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

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

  

npm ERR! JSON.parse Falied to parse json

Notice that one of the lines reads as follows:

  

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

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

Since the --save argument is used, the dependency is saved in package.json , in the dependencies node:

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

Since the package.json file was created without content and parse failed, npm can not save dependency.

How to solve the problem?

As the package.json file is blank, simply delete it and execute the command on the terminal inside the project folder. The command will automatically create the package.json file:

npm init

After answering some questions in the terminal, notice that 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. / p>

To add the dependency, run the command:

npm install angularjs-dragula --save

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

    
05.07.2018 / 16:34