“Couldn't read dependencies” error with npm

前端 未结 17 2608
别跟我提以往
别跟我提以往 2020-12-23 14:59

I wanted to start a Node app and created a package.json file with a tutorial. Here is the json file:

{
    \"name\": \"Dashboard\",         


        
相关标签:
17条回答
  • 2020-12-23 15:11

    I got the same exception also, but it was previously running fine in another machine. Anyway above solution didn't worked for me. What i did to resolve it?

    1. Copy dependencies list into clipboard.
    2. enter "npm init" to create fresh new package.json
    3. Paste the dependencies again back to package.json
    4. run "npm install" again!

    Done :) Hope it helps.

    0 讨论(0)
  • 2020-12-23 15:13

    It's simple, you're just not in the right directory.

    Go to the C:\Program Files\nodejs\node_modules\npm and you should be able to run this command properly.

    0 讨论(0)
  • 2020-12-23 15:16

    Try to update npm,It works for me

    [sudo] npm install -g npm
    
    0 讨论(0)
  • 2020-12-23 15:17

    I got this error when I had a space in my "name" within the packagae.json file.

    "NPM Project" rather than "NPMProject"

    0 讨论(0)
  • 2020-12-23 15:17

    I was following a doc on line and thought this error meant a problem with the dependencies in NPM. however after a third look. I realized that it was a typo. I did not add a comma after the first dependency in package.json that the tutorial asked me to edit.

    0 讨论(0)
  • 2020-12-23 15:19

    Try to add this:

    "private": true,

    it worked for me.

    EDIT (for people asking why):

    The Oficial documentation states the following:


    If you set "private": true in your package.json, then npm will refuse to publish it. This is a way to prevent accidental publication of private repositories. If you would like to ensure that a given package is only ever published to a specific registry (for example, an internal registry), then use the publishConfig hash described below to override the registry config param at publish-time.


    The error messages you are getting may be related to violating this "rule" in a way (mine was).

    • Either you are marking a unpublished package (like your own app) as "private": false.
    • Or you are neglecting to include any value at all.
    0 讨论(0)
提交回复
热议问题