因node-sass版本问题报错信息以及简单的解决的方式

前几天新接到一个react项目,拿到手开始搭建本地的环境,但是环境总是搭建不成功,出现各种各样的问题;

最开始是以为这个是因为之前的项目开发是mac系统进行的,而自己现在使用的系统是windows,所以出现的部分文件的兼容的问题,但是后来发现不是这个原因造成,继续寻找其他的原因;

在调试很长时间无果之后,开始重新逐个安装项目依赖包,因为毕竟这个项目是很早之前的,所以可能会出现这种问题,在重新安装依赖后,又出现了新的问题,而且是一个非常奇葩的问题,window对象找不到,这就令人无语了;

令人崩溃的尝试后,用了同事的mac系统暂时解决了急需修改的 bug,之后从他那里拷来了修改之后的项目,这次重新安装依赖包后发现项目已经能够在本地跑起来了,此时的心理有一晚句mmp在奔腾。

既然项目能够跑通说明之前的问题都是不正确的,最终经过排除,发现了问题出现的原因,node-sass版本,之前虽然重新安装了node-sass,但是依旧存在问题:在使用npm i 之后给出的报错信息如下

 [email protected] preinstall C:\Users\Dell\Desktop\demoProject\node_modules\extract-opts\node_modules\typechecker
> node ./cyclic.js


> [email protected] preinstall C:\Users\Dell\Desktop\demoProject\node_modules\extendr\node_modules\typechecker
> node ./cyclic.js


> [email protected] install C:\Users\Dell\Desktop\demoProject\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":

HTTP error 404 Not Found

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> [email protected] install C:\Users\Dell\Desktop\demoProject\node_modules\pre-commit
> node install.js

pre-commit:
pre-commit: Detected an existing git pre-commit hook
pre-commit: Old pre-commit hook backuped to pre-commit.old
pre-commit:

> [email protected] postinstall C:\Users\Dell\Desktop\demoProject\node_modules\spawn-sync
> node postinstall


> [email protected] postinstall C:\Users\Dell\Desktop\demoProject\node_modules\node-sass
> node scripts/build.js

Building: C:\Program Files\nodejs\node.exe C:\Users\Dell\Desktop\demoProject\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Dell\Desktop\demoProject\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Dell\Desktop\demoProject\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Dell\Desktop\demoProject\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Dell\Desktop\demoProject\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Dell\Desktop\demoProject\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\which\\which.js:13:12)\n    at F (C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\which\\which.js:68:19)\n    at E (C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\which\\which.js:80:29)\n    at C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\which\\which.js:89:16\n    at C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\isexe\\index.js:42:5\n    at C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Dell\AppData\Local\Programs\Python\Python35-32\python.EXE
gyp verb check python version `C:\Users\Dell\AppData\Local\Programs\Python\Python35-32\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.5.2\r\n"
gyp verb could not find "C:\Users\Dell\AppData\Local\Programs\Python\Python35-32\python.EXE". checking python launcher
gyp verb could not find "C:\Users\Dell\AppData\Local\Programs\Python\Python35-32\python.EXE". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\Dell\AppData\Local\Programs\Python\Python35-32\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Users\Dell\Desktop\demoProject\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\Dell\Desktop\demoProject\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Users\Dell\Desktop\demoProject\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Dell\\Desktop\\demoProject\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Dell\Desktop\demoProject\node_modules\node-sass
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm WARN [email protected] requires a peer of webpack@^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

嗯,总算是发现了问题的所在,那么这样的话,就能处理了;

处理的方式有很多种,在这里我说一下我处理的方式,刚开始是直接下载其他版本,但是问题依旧存在,最后处理的方式就是:

打开当前的项目的package.json文件,找到devDependencies对象,删除里面的node-sass对应的键值对,然后重新在终端npm i node-sass/cnpm i node-sass

这样重新跑一下项目,ok,问题解决了;



猜你喜欢

转载自blog.csdn.net/mulige/article/details/79358952
今日推荐