简体   繁体   English

Docker npm安装失败

[英]Docker npm install fails

I'm trying to build an ASP.Net 5.0 web app using Docker, but it fails when it reaches the npm install step, with: 我正在尝试使用Docker构建一个ASP.Net 5.0 Web应用程序,但它在到达npm安装步骤时失败,其中:

Step 14 : RUN npm install
 ---> Running in 15c191d1ca1d
npm WARN deprecated gulp-karma@0.0.4: Please use Karma directly: https://github.com/karma-runner/gulp-karma
npm WARN deprecated graceful-fs@3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated graceful-fs@1.2.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated graceful-fs@2.0.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN prefer global typescript@1.5.3 should be installed with -g
npm WARN prefer global node-gyp@3.3.1 should be installed with -g

> node-sass@3.4.2 install /app/src/CDWebDesigner/node_modules/node-sass
> node scripts/install.js

Binary downloaded and installed at /app/src/CDWebDesigner/node_modules/node-sass/vendor/linux-x64-11/binding.node

> spawn-sync@1.0.15 postinstall /app/src/CDWebDesigner/node_modules/spawn-sync
> node postinstall

Installing native dependencies (this may take up to a minute)

> node-sass@3.4.2 postinstall /app/src/CDWebDesigner/node_modules/node-sass
> node scripts/build.js



The command 'npm install' returned a non-zero code: 1

ERROR: Build failed with: exit status 1

I can't see any errors here that explain why it's failing, only WARNings. 我在这里看不到有任何错误可以解释为什么它失败了,只有WARNings。 I assume this must either be a problem with the npm installation or the modules it's trying to install. 我认为这必须是npm安装的问题或它试图安装的模块。 loadash@1.0.2 says it will fail on newer npm installs, but I don't know how to update this, or which of the dependencies is pulling this in. loadash@1.0.2表示它会在较新的npm安装上失败,但我不知道如何更新它,或者哪个依赖项正在将其添加进去。

Dockerfile Dockerfile

FROM microsoft/aspnet:1.0.0-rc1-final

RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs
RUN apt-get install bzip2

RUN curl -L https://npmjs.org/install.sh | sh

# Install bower
RUN npm install -g bower

# Install Gulp
RUN npm install -g gulp

# Install Git (for bower)
RUN apt-get -y install git

COPY . /app
WORKDIR /app
RUN ["dnu", "restore"]

WORKDIR ./src/myapp

RUN ["npm", "install"]
RUN ["bower", "install", "--allow-root"]
RUN ["gulp", "prod"]

EXPOSE 5000
CMD dnx kestrel

package.json 的package.json

{
  "name": "ASP.NET",
  "version": "0.0.0",
  "devDependencies": {
    "gulp": "3.8.11",
    "gulp-concat": "2.5.2",
    "gulp-cssmin": "0.1.7",
    "gulp-uglify": "1.2.0",
    "del": "^2.2.0",
    "gulp-sass": "^2.0.4",
    "gulp-typescript": "~2.8.0",
    "main-bower-files": "~2.9.0",
    "gulp-sourcemaps": "~1.5.2",
    "mocha": "~2.2.5",
    "gulp-mocha": "~2.1.3",
    "karma-chai": "~0.1.0",
    "chai": "~3.2.0",
    "karma": "~0.13.9",
    "karma-jasmine": "~0.3.6",
    "karma-phantomjs-launcher": "~0.2.1",
    "karma-spec-reporter": "~0.0.20",
    "gulp-karma": "^0.0.4",
    "gulp-js-obfuscator": "~1.0.0",
    "gulp-order": "^1.1.1",
    "gulp-debug": "^2.1.2"
  }
}

Not sure, but 1st: you can try install with sudo npm install, and 2nd you can try to install on this machine node-gyp and pyton 2.7 . 不确定,但是第一:您可以尝试使用sudo npm install进行安装,第二步可以尝试在此机器上安装node-gyp和pyton 2.7。 If module during installation require compilation of node extension, then you will need these two things. 如果安装期间的模块需要编译节点扩展,那么您将需要这两件事。

3rd. 3。 How we usually debug: Create an image on the state before failing command. 我们通常如何调试:在失败命令之前在状态上创建映像。 run container with interactive shell (with -it). 使用交互式shell运行容器(使用-it)。 login inside. 登录里面。 And run npm install by hands. 并且手动运行npm install。 See and understand output there. 在那里查看并了解输出。 Fix. 固定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM