虽然我在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
答案 0 :(得分:0)
没有 - 生产npm install
。它应该安装在node_modules