{
  "dependencies": {
    "axios": "^0.18.0",
    "babel-core": "^6.26.0",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.2",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "babel-preset-stage-3": "^6.24.1",
    "cookie-parser": "^1.4.3",
    "css-loader": "^0.28.9",
    "ejs": "^2.5.7",
    "express-session": "^1.15.6",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.6",
    "html-webpack-plugin": "^2.30.1",
    "leanengine": "^2.0.5",
    "node-fetch": "^2.0.0",
    "node-sass": "^4.7.2",
    "sass-loader": "^6.0.6",
    "session-file-store": "^1.2.0",
    "style-loader": "^0.20.1",
    "supervisor": "^0.12.0",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "vue": "^2.5.13",
    "vue-loader": "^13.7.1",
    "vue-router": "^3.0.1",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.13",
    "webpack": "^3.10.0",
    "webpack-dev-server": "^2.11.1",
    "safe-buffer": "~5.1.1"
  },
  "engines": {
    "node": "8.x"
  }
}

> 正在检测运行时
 > 检测到 node.js 运行时
 > 压缩项目文件
 > 上传应用文件 2.22 MB / 2.22 MB [=================================] 100.00% 2s
 > 等待文件同步
 > [REMOTE] 开始构建 20180306-094317
 > [REMOTE] 正在下载应用代码 ...
 > [REMOTE] 正在解压缩应用代码 ...
 > [REMOTE] 运行环境: nodejs (leanengine/nodejs-base)
 > [REMOTE] 正在下载和安装依赖项 ...
   [REMOTE] 部署失败:> node-sass@4.7.2 install /home/leanengine/app/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://npm.taobao.org/mirrors/node-sass//v4.7.2/linux-x64-57_binding.node
Download complete
Binary saved to /home/leanengine/app/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /home/leanengine/.npm/node-sass/4.7.2/linux-x64-57_binding.node

> node-sass@4.7.2 postinstall /home/leanengine/app/node_modules/node-sass
> node scripts/build.js

Binary found at /home/leanengine/app/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine

> uglifyjs-webpack-plugin@0.4.6 postinstall /home/leanengine/app/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added
<ignored...>
: readable-stream@2.2.9, required by tar-pack@3.4.0
npm ERR! missing: rimraf@2.6.1, required by tar-pack@3.4.0
npm ERR! missing: tar@2.2.1, required by tar-pack@3.4.0
npm ERR! missing: fstream@1.0.11, required by fstream-ignore@1.0.5
npm ERR! missing: inherits@2.0.3, required by fstream-ignore@1.0.5
npm ERR! missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: buffer-shims@1.0.0, required by readable-stream@2.2.9
npm ERR! missing: core-util-is@1.0.2, required by readable-stream@2.2.9
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.2.9
npm ERR! missing: isarray@1.0.0, required by readable-stream@2.2.9
npm ERR! missing: process-nextick-args@1.0.7, required by readable-stream@2.2.9
npm ERR! missing: string_decoder@1.0.1, required by readable-stream@2.2.9
npm ERR! missing: util-deprecate@1.0.2, required by readable-stream@2.2.9
 >  ERR! missing: safe-buffer@5.0.1, required by string_decoder@1.0.1
 > 删除临时文件
部署失败

搜索了社区的相关内容,但未找到解决问题的方法,望能回复

E:\demos>npm install --production
npm WARN prefer global node-gyp@3.6.2 should be installed with -g

node-sass@4.7.2 install E:\demos\node_modules\node-sass
node scripts/install.js

Cached binary found at d:\nodejs\node_cache\node-sass\4.7.2\win32-x64-57_binding.node

fsevents@1.1.3 install E:\demos\node_modules\fsevents
node install

uglifyjs-webpack-plugin@0.4.6 postinstall E:\demos\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js

node-sass@4.7.2 postinstall E:\demos\node_modules\node-sass
node scripts/build.js

Binary found at E:\demos\node_modules\node-sass\vendor\win32-x64-57\binding.node
Testing binary
Binary is fine
added 1180 packages in 29.537s

本地没有报错

是删除 node_modules 之后重新运行的么?

是的,删除了项目的node_modules目录再进行npm install --production

我这里用你前面发的 package.json 在 node v8.9.4 (npm v5.6.0) 是可以重现这个问题的:

root@4c239a7862f8:~# cat > package.json
{
  "dependencies": {
    "axios": "^0.18.0",
    "babel-core": "^6.26.0",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.2",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "babel-preset-stage-3": "^6.24.1",
    "cookie-parser": "^1.4.3",
    "css-loader": "^0.28.9",
    "ejs": "^2.5.7",
    "express-session": "^1.15.6",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.6",
    "html-webpack-plugin": "^2.30.1",
    "leanengine": "^2.0.5",
    "node-fetch": "^2.0.0",
    "node-sass": "^4.7.2",
    "sass-loader": "^6.0.6",
    "session-file-store": "^1.2.0",
    "style-loader": "^0.20.1",
    "supervisor": "^0.12.0",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "vue": "^2.5.13",
    "vue-loader": "^13.7.1",
    "vue-router": "^3.0.1",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.13",
    "webpack": "^3.10.0",
    "webpack-dev-server": "^2.11.1",
    "safe-buffer": "~5.1.1"
  },
  "engines": {
    "node": "8.x"
  }
}
root@4c239a7862f8:~# npm install --production --registry=http://registry.npm.taobao.org --disturl=http://npm.taobao.org/dist --sass-binary-site=https://npm.taobao.org/mirrors/node-sass/

> node-sass@4.7.2 install /root/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://npm.taobao.org/mirrors/node-sass//v4.7.2/linux-x64-57_binding.node
Download complete..] - :
Binary saved to /root/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /root/.npm/node-sass/4.7.2/linux-x64-57_binding.node

> uglifyjs-webpack-plugin@0.4.6 postinstall /root/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> node-sass@4.7.2 postinstall /root/node_modules/node-sass
> node scripts/build.js

Binary found at /root/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN root No description
npm WARN root No repository field.
npm WARN root No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 1121 packages in 46.202s
root@4c239a7862f8:~# npm list --depth 0
/root
+-- axios@0.18.0
+-- babel-core@6.26.0
+-- babel-helper-vue-jsx-merge-props@2.0.3
+-- babel-loader@7.1.3
+-- babel-plugin-syntax-jsx@6.18.0
+-- babel-plugin-transform-runtime@6.23.0
+-- babel-plugin-transform-vue-jsx@3.7.0
+-- babel-preset-env@1.6.1
+-- babel-preset-stage-2@6.24.1
+-- babel-preset-stage-3@6.24.1
+-- cookie-parser@1.4.3
+-- css-loader@0.28.10
+-- ejs@2.5.7
+-- express-session@1.15.6
+-- extract-text-webpack-plugin@3.0.2
+-- file-loader@1.1.11
+-- html-webpack-plugin@2.30.1
+-- leanengine@2.0.5
+-- node-fetch@2.1.1
+-- node-sass@4.7.2
+-- safe-buffer@5.1.1
+-- sass-loader@6.0.7
+-- session-file-store@1.2.0
+-- style-loader@0.20.2
+-- supervisor@0.12.0
+-- uglifyjs-webpack-plugin@1.2.2
+-- vue@2.5.13
+-- vue-loader@13.7.1
+-- vue-router@3.0.1
+-- vue-style-loader@3.1.2
+-- vue-template-compiler@2.5.13
+-- webpack@3.11.0
`-- webpack-dev-server@2.11.2

npm ERR! peer dep missing: ajv@^6.0.0, required by ajv-keywords@3.1.0
npm ERR! peer dep missing: ajv@^6.0.0, required by ajv-keywords@3.1.0
npm ERR! peer dep missing: ajv@^6.0.0, required by ajv-keywords@3.1.0
npm ERR! peer dep missing: ajv@^6.0.0, required by ajv-keywords@3.1.0
npm ERR! missing: hawk@3.1.3, required by node-pre-gyp@0.6.39
npm ERR! missing: mkdirp@0.5.1, required by node-pre-gyp@0.6.39
npm ERR! missing: rimraf@2.6.1, required by node-pre-gyp@0.6.39
npm ERR! missing: tar@2.2.1, required by node-pre-gyp@0.6.39
npm ERR! missing: boom@2.10.1, required by hawk@3.1.3
npm ERR! missing: cryptiles@2.0.5, required by hawk@3.1.3
npm ERR! missing: hoek@2.16.3, required by hawk@3.1.3
npm ERR! missing: sntp@1.0.9, required by hawk@3.1.3
npm ERR! missing: hoek@2.16.3, required by boom@2.10.1
npm ERR! missing: boom@2.10.1, required by cryptiles@2.0.5
npm ERR! missing: hoek@2.16.3, required by sntp@1.0.9
npm ERR! missing: minimist@0.0.8, required by mkdirp@0.5.1
npm ERR! missing: console-control-strings@1.1.0, required by npmlog@4.1.0
npm ERR! missing: readable-stream@2.2.9, required by are-we-there-yet@1.1.4
npm ERR! missing: console-control-strings@1.1.0, required by gauge@2.7.4
npm ERR! missing: string-width@1.0.2, required by gauge@2.7.4
npm ERR! missing: strip-ansi@3.0.1, required by gauge@2.7.4
npm ERR! missing: code-point-at@1.1.0, required by string-width@1.0.2
npm ERR! missing: is-fullwidth-code-point@1.0.0, required by string-width@1.0.2
npm ERR! missing: strip-ansi@3.0.1, required by string-width@1.0.2
npm ERR! missing: number-is-nan@1.0.1, required by is-fullwidth-code-point@1.0.0
npm ERR! missing: ansi-regex@2.1.1, required by strip-ansi@3.0.1
npm ERR! missing: string-width@1.0.2, required by wide-align@1.1.2
npm ERR! missing: combined-stream@1.0.5, required by request@2.81.0
npm ERR! missing: hawk@3.1.3, required by request@2.81.0
npm ERR! missing: mime-types@2.1.15, required by request@2.81.0
npm ERR! missing: safe-buffer@5.0.1, required by request@2.81.0
npm ERR! missing: delayed-stream@1.0.0, required by combined-stream@1.0.5
npm ERR! missing: combined-stream@1.0.5, required by form-data@2.1.4
npm ERR! missing: mime-types@2.1.15, required by form-data@2.1.4
npm ERR! missing: extsprintf@1.0.2, required by jsprim@1.4.0
npm ERR! missing: extsprintf@1.0.2, required by verror@1.3.6
npm ERR! missing: mime-db@1.27.0, required by mime-types@2.1.15
npm ERR! missing: safe-buffer@5.0.1, required by tunnel-agent@0.6.0
npm ERR! missing: glob@7.1.2, required by rimraf@2.6.1
npm ERR! missing: fs.realpath@1.0.0, required by glob@7.1.2
npm ERR! missing: inflight@1.0.6, required by glob@7.1.2
npm ERR! missing: inherits@2.0.3, required by glob@7.1.2
npm ERR! missing: minimatch@3.0.4, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by glob@7.1.2
npm ERR! missing: path-is-absolute@1.0.1, required by glob@7.1.2
npm ERR! missing: once@1.4.0, required by inflight@1.0.6
npm ERR! missing: wrappy@1.0.2, required by inflight@1.0.6
npm ERR! missing: brace-expansion@1.1.7, required by minimatch@3.0.4
npm ERR! missing: balanced-match@0.4.2, required by brace-expansion@1.1.7
npm ERR! missing: concat-map@0.0.1, required by brace-expansion@1.1.7
npm ERR! missing: block-stream@0.0.9, required by tar@2.2.1
npm ERR! missing: fstream@1.0.11, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by tar@2.2.1
npm ERR! missing: inherits@2.0.3, required by block-stream@0.0.9
npm ERR! missing: graceful-fs@4.1.11, required by fstream@1.0.11
npm ERR! missing: inherits@2.0.3, required by fstream@1.0.11
npm ERR! missing: mkdirp@0.5.1, required by fstream@1.0.11
npm ERR! missing: rimraf@2.6.1, required by fstream@1.0.11
npm ERR! missing: fstream@1.0.11, required by tar-pack@3.4.0
npm ERR! missing: once@1.4.0, required by tar-pack@3.4.0
npm ERR! missing: readable-stream@2.2.9, required by tar-pack@3.4.0
npm ERR! missing: rimraf@2.6.1, required by tar-pack@3.4.0
npm ERR! missing: tar@2.2.1, required by tar-pack@3.4.0
npm ERR! missing: fstream@1.0.11, required by fstream-ignore@1.0.5
npm ERR! missing: inherits@2.0.3, required by fstream-ignore@1.0.5
npm ERR! missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: buffer-shims@1.0.0, required by readable-stream@2.2.9
npm ERR! missing: core-util-is@1.0.2, required by readable-stream@2.2.9
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.2.9
npm ERR! missing: isarray@1.0.0, required by readable-stream@2.2.9
npm ERR! missing: process-nextick-args@1.0.7, required by readable-stream@2.2.9
npm ERR! missing: string_decoder@1.0.1, required by readable-stream@2.2.9
npm ERR! missing: util-deprecate@1.0.2, required by readable-stream@2.2.9
npm ERR! missing: safe-buffer@5.0.1, required by string_decoder@1.0.1

可以先尝试把 ajv 加到 dependencies 里。

1 人赞了这个帖子.

E:\demos>npm install --production
npm WARN prefer global node-gyp@3.6.2 should be installed with -g

node-sass@4.7.2 install E:\demos\node_modules\node-sass
node scripts/install.js

Cached binary found at d:\nodejs\node_cache\node-sass\4.7.2\win32-x64-57_binding.node

fsevents@1.1.3 install E:\demos\node_modules\fsevents
node install

uglifyjs-webpack-plugin@0.4.6 postinstall E:\demos\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js

node-sass@4.7.2 postinstall E:\demos\node_modules\node-sass
node scripts/build.js

Binary found at E:\demos\node_modules\node-sass\vendor\win32-x64-57\binding.node
Testing binary
Binary is fine
added 1180 packages in 29.476s

E:\demos>node -v
v8.0.0

我本地,一直都是可以成功运行,但是都是lean deploy 到线上就一直会报错。对部署这方面不太了解

把 ajv 加到 dependencies 里试试看?

packpackage.json
{
"name": "demos",
"version": "1.0.0",
"description": "all kinds of examples",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack-dev-server --inline --progress --port 8000",
"build": "webpack --progress --hide-modules",
"start": "node --harmony backend-server/server.js"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/jantoChan/demos.git"
},
"author": "jantoChan",
"license": "ISC",
"bugs": {
"url": "https://github.com/jantoChan/demos/issues"
},
"homepage": "https://github.com/jantoChan/demos#readme",
"dependencies": {
"ajv": "^6.2.1",
"axios": "^0.18.0",
"babel-core": "^6.26.0",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.2",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-preset-stage-3": "^6.24.1",
"cookie-parser": "^1.4.3",
"css-loader": "^0.28.9",
"ejs": "^2.5.7",
"express-session": "^1.15.6",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.6",
"html-webpack-plugin": "^2.30.1",
"leanengine": "^2.0.5",
"node-fetch": "^2.0.0",
"node-sass": "^4.7.2",
"sass-loader": "^6.0.6",
"session-file-store": "^1.2.0",
"style-loader": "^0.20.1",
"supervisor": "^0.12.0",
"uglifyjs-webpack-plugin": "^1.1.1",
"vue": "^2.5.13",
"vue-loader": "^13.7.1",
"vue-router": "^3.0.1",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.11.1"
},
"engines": {
"node": "8.x"
}
}

有报其他的错:
: readable-stream@2.2.9, required by tar-pack@3.4.0
npm ERR! missing: rimraf@2.6.1, required by tar-pack@3.4.0
npm ERR! missing: tar@2.2.1, required by tar-pack@3.4.0
npm ERR! missing: fstream@1.0.11, required by fstream-ignore@1.0.5
npm ERR! missing: inherits@2.0.3, required by fstream-ignore@1.0.5
npm ERR! missing: minimatch@3.0.4, required by fstream-ignore@1.0.5
npm ERR! missing: wrappy@1.0.2, required by once@1.4.0
npm ERR! missing: buffer-shims@1.0.0, required by readable-stream@2.2.9
npm ERR! missing: core-util-is@1.0.2, required by readable-stream@2.2.9
npm ERR! missing: inherits@2.0.3, required by readable-stream@2.2.9
npm ERR! missing: isarray@1.0.0, required by readable-stream@2.2.9
npm ERR! missing: process-nextick-args@1.0.7, required by readable-stream@2.2.9
npm ERR! missing: string_decoder@1.0.1, required by readable-stream@2.2.9
npm ERR! missing: util-deprecate@1.0.2, required by readable-stream@2.2.9
npm ERR! missing: safe-buffer@5.0.1, required by string_decoder@1.0.1

看起来是 npm 5.6 的 bug https://github.com/npm/npm/issues/1939311

我退回到 node v8.8.1 (npm v5.4.2) 就没有这个问题了,你可以先在 engines.node 里写 8.8 来绕过这个问题。

感谢帮忙,确实是跟一些版本有关系。经过修改之后解决了。