我正在做一个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 : 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“
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文件
{
"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发布于 2020-11-20 18:38:21
使用node:14。适用于我!:
docker run -it node:14 npm install -g npm@7.0.12https://stackoverflow.com/questions/64868897
复制相似问题