npm install报错(The platform “win32“ is incompatible with this module)

问题背景

最近入门Vue,那么使用了最新的nodejsyarnnpm,使用vue-cli脚手架新建项目之后进行npm install / yarn install ,结果发现以下报错,报错信息非常费解,因为提示的是python2不适合当前平台?一脸问号。

d:\workspace\vue\vue-study
λ yarn install
yarn install v1.22.4
info No lockfile found.
[1/4] Resolving packages...
warning babel-core > babel-runtime > [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
warning babel-core > babel-register > [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
warning css-loader > cssnano > autoprefixer > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning css-loader > cssnano > postcss-merge-rules > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning css-loader > cssnano > postcss-merge-rules > caniuse-api > [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning node-sass > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
warning node-sass > node-gyp > [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
warning webpack > watchpack > watchpack-chokidar2 > [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning webpack > watchpack > watchpack-chokidar2 > chokidar > [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning webpack > watchpack > watchpack-chokidar2 > chokidar > braces > snapdragon > source-map-resolve > [email protected]: https://github.com/lydell/resolve-url#deprecated
warning webpack > watchpack > watchpack-chokidar2 > chokidar > braces > snapdragon > source-map-resolve > [email protected]: Please see https://github.com/lydell/urix#deprecated
warning webpack-dev-server > [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[-/3] ⠈ waiting...
[-/3] ⠁ waiting...
error d:\workspace\vue\vue-study\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: d:\workspace\vue\vue-study\node_modules\node-sass
Output:
Building: D:\software\nodejs\node.exe d:\workspace\vue\vue-study\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 [
gyp verb cli   'D:\\software\\nodejs\\node.exe',
gyp verb cli   'd:\\workspace\\vue\\vue-study\\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 verb cli ]
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 (d:\workspace\vue\vue-study\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (d:\workspace\vue\vue-study\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (d:\workspace\vue\vue-study\node_modules\which\which.js:80:29)
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\which\which.js:89:16
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (d:\workspace\vue\vue-study\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (d:\workspace\vue\vue-study\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (d:\workspace\vue\vue-study\node_modules\which\which.js:80:29)
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\which\which.js:89:16
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (d:\workspace\vue\vue-study\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (d:\workspace\vue\vue-study\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (d:\workspace\vue\vue-study\node_modules\which\which.js:80:29)
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\which\which.js:89:16
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (d:\workspace\vue\vue-study\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (d:\workspace\vue\vue-study\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (d:\workspace\vue\vue-study\node_modules\which\which.js:80:29)
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\which\which.js:89:16
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at d:\workspace\vue\vue-study\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". 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 "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (d:\workspace\vue\vue-study\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (d:\workspace\vue\vue-study\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at callback (d:\workspace\vue\vue-study\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:167:21)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "D:\\software\\nodejs\\node.exe" "d:\\workspace\\vue\\vue-study\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd d:\workspace\vue\vue-study\node_modules\node-sass
gyp ERR! node -v v12.18.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

网上说这个方法,但是实际上也没什么用

yarn config set ignore-engines true

解决方案

最终是通过管理员模式运行控制台,可能要有些安装命令需要权限,普通运行无法安装,所以会卡主。

例如我用yarn,就使用以下的,如果是npm,就

yarn global add windows-build-tools
yarn install

npm请使用:

npm install windows-build-tools --g
npm install

猜你喜欢

转载自blog.csdn.net/moshowgame/article/details/107204811