关于node.js:除非首先删除node_modules文件夹,否则NPM安装无法正常工作?

NPM install not working unless node_modules folder is first deleted?

我有一个Visual Studio团队服务构建定义,第一步是" npm install"。此定义将部署到azure Web应用程序。

NPM顺利完成,但是在访问Web应用程序时,引发错误"找不到模块'express'"。从Web应用程序文件和package.json所在的" wwwroot"文件夹中手动运行" npm install"时,该命令再次成功完成,但错误仍然存??在。

但是,当我从" wwwroot"文件夹中删除" node_modules"并再次运行" npm install"时,错误消失了,Web应用程序将按预期运行!

如何修复我的构建定义,以便在每个部署中都不需要这些手动步骤?

我的package.json中的相关摘录如下:

1
2
3
4
5
"dependencies": {
   "express":"^4.13.4",
   "pug":"^2.0.0-alpha7",
   "bluebird":"^3.4.1",
},

npm日志在下面可用:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    2016-08-21T01:19:28.9476070Z ##[debug]check path : C:\\LR\\MMS\\Services\\Mms\\TaskAgentProvisioner\\Tools\\agents\\1.104.1\\tasks\
pm\\0.2.15\\task.json
2016-08-21T01:19:28.9476070Z ##[debug]set resource file to: C:\\LR\\MMS\\Services\\Mms\\TaskAgentProvisioner\\Tools\\agents\\1.104.1\\tasks\
pm\\0.2.15\\task.json
2016-08-21T01:19:28.9486073Z ##[debug]system.culture=en-US
2016-08-21T01:19:28.9646119Z ##[debug]check path : C:\\Program Files\
odejs\
pm.cmd
2016-08-21T01:19:28.9656074Z ##[debug]npm=C:\\Program Files\
odejs\
pm.cmd
2016-08-21T01:19:28.9666075Z ##[debug]cwd=C:\\a\\1\\s
2016-08-21T01:19:28.9686074Z ##[debug]path exists: C:\\a\\1\\s
2016-08-21T01:19:28.9696068Z ##[debug]command=install
2016-08-21T01:19:28.9696068Z ##[debug]C:\\Program Files\
odejs\
pm.cmd arg: install
2016-08-21T01:19:28.9706071Z ##[debug]arguments=null
2016-08-21T01:19:28.9706071Z ##[debug]exec tool: C:\\Program Files\
odejs\
pm.cmd
2016-08-21T01:19:28.9716073Z ##[debug]Arguments:
2016-08-21T01:19:28.9716073Z ##[debug]   install
2016-08-21T01:19:28.9726071Z [command]C:\\Program Files\
odejs\
pm.cmd install
2016-08-21T01:19:43.5330503Z [email protected] C:\\a\\1\\s
2016-08-21T01:19:43.5330503Z +-- [email protected]
2016-08-21T01:19:43.5340519Z | +-- [email protected]
2016-08-21T01:19:43.5340519Z | | +-- [email protected]
2016-08-21T01:19:43.5340519Z | | | +-- [email protected]
2016-08-21T01:19:43.5350499Z | | | +-- [email protected]
2016-08-21T01:19:43.5350499Z | | | `-- [email protected]
2016-08-21T01:19:43.5360508Z | | `-- [email protected]
2016-08-21T01:19:43.5360508Z | |   `-- [email protected]
2016-08-21T01:19:43.5370502Z | `-- [email protected]
2016-08-21T01:19:43.5370502Z |   `-- [email protected]
2016-08-21T01:19:43.5370502Z |     `-- [email protected]
2016-08-21T01:19:43.5380497Z |       +-- [email protected]
2016-08-21T01:19:43.5380497Z |       `-- [email protected]
2016-08-21T01:19:43.5390498Z +-- [email protected]
2016-08-21T01:19:43.5390498Z | +-- [email protected]
2016-08-21T01:19:43.5390498Z | | `-- [email protected]
2016-08-21T01:19:43.5400508Z | |   `-- [email protected]
2016-08-21T01:19:43.5400508Z | +-- [email protected]
2016-08-21T01:19:43.5420690Z | +-- [email protected]
2016-08-21T01:19:43.5420690Z | +-- [email protected]
2016-08-21T01:19:43.5430497Z | +-- [email protected]
2016-08-21T01:19:43.5430497Z | | `-- [email protected]
2016-08-21T01:19:43.5440674Z | +-- [email protected]
2016-08-21T01:19:43.5440674Z | +-- [email protected]
2016-08-21T01:19:43.5450502Z | +-- [email protected]
2016-08-21T01:19:43.5450502Z | +-- [email protected]
2016-08-21T01:19:43.5460530Z | | `-- [email protected]
2016-08-21T01:19:43.5460530Z | +-- [email protected]
2016-08-21T01:19:43.5470497Z | +-- [email protected]
2016-08-21T01:19:43.5470497Z | +-- [email protected]
2016-08-21T01:19:43.5480496Z | +-- [email protected]
2016-08-21T01:19:43.5480496Z | | `-- [email protected]
2016-08-21T01:19:43.5490499Z | +-- [email protected]
2016-08-21T01:19:43.5490499Z | +-- [email protected]
2016-08-21T01:19:43.5500513Z | +-- [email protected]
2016-08-21T01:19:43.5500513Z | | `-- [email protected]
2016-08-21T01:19:43.5500513Z | +-- [email protected]
2016-08-21T01:19:43.5510491Z | | +-- [email protected]
2016-08-21T01:19:43.5510491Z | | `-- [email protected]
2016-08-21T01:19:43.5520499Z | +-- [email protected]
2016-08-21T01:19:43.5520499Z | | `-- [email protected]
2016-08-21T01:19:43.5520499Z | `-- [email protected]
2016-08-21T01:19:43.5530492Z `-- [email protected]
2016-08-21T01:19:43.5530492Z   +-- [email protected]
2016-08-21T01:19:43.5540495Z   | +-- [email protected]
2016-08-21T01:19:43.5540495Z   | +-- [email protected]
2016-08-21T01:19:43.5540495Z   | +-- [email protected]
2016-08-21T01:19:43.5550503Z   | `-- [email protected]
2016-08-21T01:19:43.5550503Z   +-- [email protected]
2016-08-21T01:19:43.5550503Z   | +-- [email protected]
2016-08-21T01:19:43.5560494Z   | | `-- [email protected]
2016-08-21T01:19:43.5560494Z   | |   `-- [email protected]
2016-08-21T01:19:43.5570499Z   | +-- [email protected]
2016-08-21T01:19:43.5570499Z   | | +-- [email protected]
2016-08-21T01:19:43.5570499Z   | | `-- [email protected]
2016-08-21T01:19:43.5580491Z   | +-- [email protected]
2016-08-21T01:19:43.5580491Z   | +-- [email protected]
2016-08-21T01:19:43.5590498Z   | `-- [email protected]
2016-08-21T01:19:43.5590498Z   |   +-- [email protected]
2016-08-21T01:19:43.5590498Z   |   +-- [email protected]
2016-08-21T01:19:43.5600495Z   |   `-- [email protected]
2016-08-21T01:19:43.5600495Z   |     +-- [email protected]
2016-08-21T01:19:43.5600495Z   |     +-- [email protected]
2016-08-21T01:19:43.5610497Z   |     | +-- [email protected]
2016-08-21T01:19:43.5610497Z   |     | | +-- [email protected]
2016-08-21T01:19:43.5620497Z   |     | | | +-- [email protected]
2016-08-21T01:19:43.5620497Z   |     | | | | `-- [email protected]
2016-08-21T01:19:43.5620497Z   |     | | | +-- [email protected]
2016-08-21T01:19:43.5630568Z   |     | | | `-- [email protected]
2016-08-21T01:19:43.5630568Z   |     | | `-- [email protected]
2016-08-21T01:19:43.5640500Z   |     | +-- [email protected]
2016-08-21T01:19:43.5640500Z   |     | `-- [email protected]
2016-08-21T01:19:43.5640500Z   |     +-- [email protected]
2016-08-21T01:19:43.5650495Z   |     `-- [email protected]
2016-08-21T01:19:43.5650495Z   +-- [email protected]
2016-08-21T01:19:43.5660502Z   | +-- [email protected]
2016-08-21T01:19:43.5660502Z   | | `-- [email protected]
2016-08-21T01:19:43.5660502Z   | `-- [email protected]
2016-08-21T01:19:43.5670500Z   |   `-- [email protected]
2016-08-21T01:19:43.5670500Z   +-- [email protected]
2016-08-21T01:19:43.5670500Z   | `-- [email protected]
2016-08-21T01:19:43.5680491Z   `-- [email protected]
2016-08-21T01:19:43.5680491Z     `-- [email protected]
2016-08-21T01:19:43.5820489Z ##[debug]rc:0
2016-08-21T01:19:43.5820489Z ##[debug]success:true
2016-08-21T01:19:43.5830501Z ##[debug]task result: Succeeded
2016-08-21T01:19:43.6100505Z Finishing task: Npm

例如," express"模块文件夹由于未知原因而丢失了其" index.js"," LICENCE"和" package.json"文件。


我尝试过使用npm install>存档文件>复制并发布构建工件> Azure Web App Deployment工作流程来安装软件包,打包应用程序并将其部署到Azure Web App。

enter