我试图运行我的项目与泊坞内的所有依赖关系,但我被卡住了咕噜依赖,出于某种原因咕噜失败,它可以发生错误找不到当地的咕噜声。错误在Docker中运行grunt:致命错误:无法找到本地grunt
我创建的如何重现这样的一个例子:
.
├── code
│ ├── bower.json
│ ├── Gruntfile.js
│ └── package.json
├── docker-compose.yml
└── frontend.dockerfile
搬运工-compose.yml:
version: "2"
services:
frontend:
build:
context: .
dockerfile: frontend.dockerfile
ports:
- "8585:8000"
volumes:
- ./code:/srv/frontend
command: grunt
frontend.dockerfile:
FROM node:wheezy
ADD code /srv/frontend
WORKDIR /srv/frontend
RUN npm install -g grunt-cli bower
RUN npm install
RUN groupadd -r usergroup && useradd -m -r -g usergroup user
RUN chown -R user:usergroup /srv/frontend
USER user
RUN bower install
bower.json:
{
"name": "code",
"description": "",
"main": "index.js",
"authors": [
"Mr. No One"
],
"license": "ISC",
"homepage": "",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": "^1.5.8"
}
}
Gruntfile.json:
module.exports = function(grunt) {
grunt.initConfig({});
// tasks
grunt.registerTask('default', []);
};
的package.json:
{
"name": "code",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"grunt": "^1.0.1"
}
}
$ docker-compose up ... installing all dependencies ...
安装后,它在尝试运行失败我指定的grunt
命令指明分数在我docker-compose.yml
文件与此错误:
frontend_1 | grunt-cli: The grunt command line interface (v1.2.0)
frontend_1 |
frontend_1 | Fatal error: Unable to find local grunt.
frontend_1 |
frontend_1 | If you're seeing this message, grunt hasn't been installed locally to
frontend_1 | your project. For more information about installing and configuring grunt,
frontend_1 | please see the Getting Started guide:
frontend_1 |
frontend_1 | http://gruntjs.com/getting-started
package.json
实际上并包括grunt
作为一个依赖,所以应该RUN npm install
后进行安装。
貌似唯一node_modules文件夹我是'''在/ usr /本地/ lib/node_modules''',node_modules和bower_components实际上是从项目文件夹中丢失的。 'NODE_ENV'''没有设置。 – vladimirze
你的'package.json'是否存在于'WORKDIR'中? –
同时在你的'command'里放一个'cwd'来看看它在哪里试图运行grunt。 –