总是从package.json本地安装npm

时间:2015-12-29 09:08:12

标签: node.js docker npm

虽然我在Docker容器中运行此设置,但我的项目文件位于/app/app/package.json存在

当我cd /app && npm install --production(以root或非root用户身份)时,所有依赖项都安装在~/.npm文件夹中,而不是显示在/app/node_modules

我也尝试过npm install --production --verbose --prefix /app,但文件夹node_modules仍未显示应用文件夹中的依赖项。

当我查看错误日志时,我会看到几乎每个依赖项的消息(例如:安装反应)。

npm verb tar unpack /root/.npm/base62/0.1.1/package.tgz
npm verb tar unpacking to /app/node_modules/react/node_modules/envify/node_modules/jstransform/node_modules/base62
npm verb gentlyRm don't care about contents; nuking /app/node_modules/react/node_modules/envify/node_modules/jstransform/node_modules/base62
npm verb gentlyRm don't care about contents; nuking /app/node_modules/react/node_modules/envify/node_modules/jstransform/node_modules/esprima-fb
npm verb tar unpack /root/.npm/source-map/0.1.31/package.tgz
npm verb tar unpacking to /app/node_modules/react/node_modules/envify/node_modules/jstransform/node_modules/source-map
npm verb gentlyRm don't care about contents; nuking /app/node_modules/react/node_modules/envify/node_modules/jstransform/node_modules/source-map
npm verb tar unpack /root/.npm/esprima-fb/13001.1001.0-dev-harmony-fb/package.tgz
npm verb tar unpacking to /app/node_modules/react/node_modules/envify/node_modules/jstransform/node_modules/esprima-fb
npm verb gentlyRm don't care about contents; nuking /app/node_modules/react/node_modules/envify/node_modules/jstransform/node_modules/esprima-fb

如果我想以root用户身份运行,如何让npm始终在{app}目录中的package.json文件夹中安装node_modules中列出的所有依赖项

使用npm@2.14.7,node@v4.2.3

1 个答案:

答案 0 :(得分:0)

没有 - 生产npm install。它应该安装在node_modules