首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行npm install npm错误!代码EJSONPARSE

运行npm install npm错误!代码EJSONPARSE
EN

Stack Overflow用户
提问于 2020-11-17 11:25:41
回答 1查看 764关注 0票数 0

我正在做一个docker课程,现在我收到了这个错误,我已经尝试了一个小时,但是仍然不能解决。寻找为什么会发生这种情况的解释。谢谢!

代码语言:javascript
复制
    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

起始节点:阿尔卑斯山

WORKDIR /usr/app

复制package.json。

运行npm安装

收到。。

CMD "npm","start“

代码语言:javascript
复制
    const express = require('express');
    const redis = require('redis');

    const app = express();
    const client = redis.createClient();
    client.set('visits', 0)

    app.get('/', (req, res) => {
      client.get('visits', (err, visits) => {
        res.send('Number of visits is ' + visits);
        client.set('visits', parseInt(visits) + 1);
      });
    });

    app.listen(8081, () => {
      console.log('Listening on port 8081');
    });

“”“

打包JSON文件

代码语言:javascript
复制
      {
          "dependencies": {
            "express": "*",
            "redis": "2.8.0"
          },
          "scripts": {
            "start": "node index.js"
          }
        }

“”“

控制台日志

代码语言:javascript
复制
    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
EN

回答 1

Stack Overflow用户

发布于 2020-11-20 18:38:21

使用node:14。适用于我!:

代码语言:javascript
复制
docker run -it node:14  npm install -g npm@7.0.12
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64868897

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档