Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 运行npm安装时出错npm错误!代码EJSONPARSE_Node.js_Docker - Fatal编程技术网

Node.js 运行npm安装时出错npm错误!代码EJSONPARSE

Node.js 运行npm安装时出错npm错误!代码EJSONPARSE,node.js,docker,Node.js,Docker,做一个码头工人的课程,我现在收到这个错误,我一直试图找出它一个小时,但仍然无法。正在寻找关于为什么会发生这种情况的解释。谢谢 abdullahyasinahmad@Abdullahs-MBP visits % docker build . Sending build context to Docker daemon 3.584kB Step 1/6 : FROM node:alpine ---> 66f36cfbf155 Step 2/6 : W

做一个码头工人的课程,我现在收到这个错误,我一直试图找出它一个小时,但仍然无法。正在寻找关于为什么会发生这种情况的解释。谢谢

    abdullahyasinahmad@Abdullahs-MBP visits % docker build .
    Sending build context to Docker daemon  3.584kB
    Step 1/6 : FROM node:alpine
     ---> 66f36cfbf155
    Step 2/6 : WORKDIR /usr/app
     ---> Using cache
     ---> c75d13f7a8d9
    Step 3/6 : COPY package.json .
     ---> Using cache
     ---> a0ad07b89732
    Step 4/6 : RUN npm install
     ---> Running in ec0f65f48bca
    npm notice 
    npm notice New patch version of npm available! 7.0.8 -> 7.0.11
    npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.11>
    npm notice Run `npm install -g npm@7.0.11` to update!
    npm notice 
    npm ERR! code EJSONPARSE
    npm ERR! path /usr/app/package.json
    npm ERR! JSON.parse Unexpected end of JSON input while parsing empty string
    npm ERR! JSON.parse Failed to parse JSON data.
    npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2020-11-17T03_15_25_297Z-debug.log
    The command '/bin/sh -c npm install' returned a non-zero code: 1
'''

包JSON文件

      {
          "dependencies": {
            "express": "*",
            "redis": "2.8.0"
          },
          "scripts": {
            "start": "node index.js"
          }
        }
'''

控制台日志

    Nov 16 22:23:29 Abdullahs-MBP com.apple.xpc.launchd[1]          
   (com.apple.xpc.launchd.domain.pid.docker-credenti.55164): Failed to bootstrap path: path=       /usr/local/bin/docker-credential-osxkeychain, error = 2: No such file or 
    directory

使用
节点:14
。为我工作!:

docker run -it node:14  npm install -g npm@7.0.12

错误:“npm ERR!JSON.parse解析空字符串时JSON输入的意外结束”表示package.JSON文件格式不正确。搜索联机JSON解析器以正确设置其格式,然后重试。共享JSON文件您可能希望尝试npm cache clean并重试安装以查看该文件helps@NirAlfasi谢谢你,所以我这么做了,效果很好,但我看不出有什么不同。。什么会导致这种情况发生?解析器没有添加任何新代码,一切都是一样的?听起来好像文件末尾有空格之类的。
docker run -it node:14  npm install -g npm@7.0.12