suchen

Heim  >  Fragen und Antworten  >  Hauptteil

node.js - npm install安装文档报错

在公司电脑上一步一步配置好的gulp正常运行没问题,然后我考U盘上带回来我自己的电脑,用

npm install

命令重新安装,总是报错,而且公司电脑配置好一个项目后再配置另外一个项目也会报错,等于同样的环境同样的操作就成功了一个项目,别的项目安装gulp-sass经常报错,非常诡异,求解,代码如下:

E:\web\b2b>cnpm install
[graceful-fs@3.0.8] deprecate: graceful-fs version 3 and before will fail on n
ewer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
install xmlhttprequest from remote https://github.com/rase-/node-XMLHttpReques
t/archive/a6b6f2.tar.gz, may be very slow, please keep patience
[lodash@1.0.2] deprecate: lodash@<3.0.0 is no longer maintained. Upgrade to lo
dash@^4.0.0.
[gulp-uglify@*] installed at node_modules\.npminstall\gulp-uglify\1.5.3\gulp-u
glify (0 packages, use 6s, speed 407.41kB/s, json 2.26MB, tarball 0B)
install global from remote https://github.com/component/global/archive/v2.0.1.
tar.gz, may be very slow, please keep patience
[graceful-fs@1.2.3] deprecate: graceful-fs version 3 and before will fail on n
ewer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
[gulp@*] installed at node_modules\.npminstall\gulp\3.9.1\gulp (0 packages, us
e 6s, speed 407.81kB/s, json 2.36MB, tarball 0B)
[gulp-clean-css@*] installed at node_modules\.npminstall\gulp-clean-css\2.0.3\
gulp-clean-css (0 packages, use 6s, speed 418.55kB/s, json 2.42MB, tarball 0B)

[gulp-autoprefixer@*] installed at node_modules\.npminstall\gulp-autoprefixer\
3.1.0\gulp-autoprefixer (0 packages, use 7s, speed 376.89kB/s, json 2.68MB, ta
rball 0B)
[fsevents@1.0.8] download from binary mirror: {"module_name":"fse","module_pat
h":"./lib/binding/{configuration}/{node_abi}-{platform}-{arch}/","remote_path"
:"./v{version}/","package_name":"{module_name}-v{version}-{node_abi}-{platform
}-{arch}.tar.gz","host":"https://npm.taobao.org/mirrors/fsevents"}
[gulp-sass@^2.2.0] installed at node_modules\.npminstall\gulp-sass\2.2.0\gulp-
sass (0 packages, use 11s, speed 302.18kB/s, json 3.27MB, tarball 0B)
[browser-sync@*] installed at node_modules\.npminstall\browser-sync\2.11.1\bro
wser-sync (0 packages, use 12s, speed 291kB/s, json 3.27MB, tarball 0B)
excute post install scripts...
[bufferutil@1.2.1] scripts.install: "node-gyp rebuild" at E:\web\b2b\node_modu
les\.npminstall\bufferutil\1.2.1\bufferutil
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the P
YTHON env variable.
gyp ERR! stack     at failNoPython (C:\Users\mqhe\AppData\Roaming\npm\node_mod
ules\cnpm\node_modules\npminstall\node_modules\node-gyp\lib\configure.js:401:1
4)
gyp ERR! stack     at C:\Users\mqhe\AppData\Roaming\npm\node_modules\cnpm\node
_modules\npminstall\node_modules\node-gyp\lib\configure.js:356:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\mqhe\\AppDa
ta\\Roaming\\npm\\node_modules\\cnpm\\node_modules\\npminstall\\node_modules\\
node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\web\b2b\node_modules\.npminstall\bufferutil\1.2.1\bufferutil
gyp ERR! node -v v4.4.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
[Error: Run "C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild" error, exi
t code 1
    at ChildProcess.<anonymous> (C:\Users\mqhe\AppData\Roaming\npm\node_module
s\cnpm\node_modules\npminstall\node_modules\runscript\index.js:67:21)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:827:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)@%
s] optional error: %s
All packages installed (486 packages installed from npm registry, 2 packages i
nstalled from remote url, use 12s, speed 275.08kB/s, json 581(3.27MB), tarball
 0B)
 

虽然提示所有包安装成功了,但是一执行gulp就会报如下错误:

E:\web\b2b>gulp
E:\web\b2b\node_modules\.npminstall\node-sass\3.4.2\node-sass\lib\extensions.j
s:158
    throw new Error([
    ^

Error: The `libsass` binding was not found in E:\web\b2b\node_modules\.npminst
all\node-sass\3.4.2\node-sass\vendor\win32-x64-46\binding.node
This usually happens because your node version has changed.
Run `npm rebuild node-sass` to build the binding for your current node version
.
    at Object.sass.getBinaryPath (E:\web\b2b\node_modules\.npminstall\node-sas
s\3.4.2\node-sass\lib\extensions.js:158:11)
    at Object.<anonymous> (E:\web\b2b\node_modules\.npminstall\node-sass\3.4.2
\node-sass\lib\index.js:16:36)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (E:\web\b2b\node_modules\.npminstall\gulp-sass\2.2.0
\gulp-sass\index.js:186:21)
    at Module._compile (module.js:409:26)

请问这是哪里出错了呀?该怎么解决呢?
我的package.json:

{
  "name": "b2b",
  "version": "1.0.0",
  "description": "B2B",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "B2B"
  ],
  "author": "qingjin",
  "license": "ISC",
  "devDependencies": {
    "gulp": "",
    "gulp-uglify": "",
    "gulp-clean-css": "",
    "gulp-sass": "",
    "gulp-autoprefixer": "",
    "browser-sync": "",
  }
}
PHP中文网PHP中文网2783 Tage vor715

Antworte allen(2)Ich werde antworten

  • PHP中文网

    PHP中文网2017-04-17 13:38:38

    你公司电脑上的node.js版本比你家里的低,卸掉你家里的node.js,安装一个低版本的。

    Antwort
    0
  • PHP中文网

    PHP中文网2017-04-17 13:38:38

    错误提示里有建议你怎么做:

    Run `npm rebuild node-sass` to build the binding for your current node version

    也就是在命令行里输入:

    npm rebuild node-sass

    Antwort
    0
  • StornierenAntwort