Ionic 3 项目中的 Node JS 和 SASS 不兼容问题
Posted
技术标签:
【中文标题】Ionic 3 项目中的 Node JS 和 SASS 不兼容问题【英文标题】:Node JS and SASS incompatibility issues in Ionic 3 project 【发布时间】:2019-10-06 02:05:33 【问题描述】:我正在尝试重建一个在另一台机器上编码的 Ionic 3.9.2 项目,并且我已经构建了一个新的 Ionic 项目并将“外部”项目文件传输到它。但是当我在终端中运行ionic serve -l
以可视化项目时,我收到了一个关于 SASS 设置的错误,如图所示:
为了修复它,我卸载了 Node JS 6.11.1 64bit 并安装了 32bit 版本。但是现在我在尝试构建项目时在终端上遇到了新错误:
首先我得到了:
错误:缺少绑定 C:\crepe\node_modules\node-sass\vendor\win32-ia32-48\binding.node Node Sass 找不到当前环境的绑定:Windows 32-bit with Node.js 6.x 找到以下环境的绑定: - 带有 Node.js 6.x 的 Windows 64 位 这通常是因为您的环境在运行
npm install
后发生了变化。 运行npm rebuild node-sass --force
为您当前的环境构建绑定。
所以我运行了指示的命令:npm rebuild node-sass --force
但现在我遇到了一大堆新错误:
node-sass@4.5.3 安装 C:\crepe\node_modules\node-sass 节点脚本/install.js 从https://github.com/sass/node-sass/releases/download/v4.5.3/win32-ia32-48_binding.node 下载二进制文件 下载完毕 ] - : 二进制保存到 C:\crepe\node_modules\node-sass\vendor\win32-ia32-48\binding.node 将二进制缓存到 C:\Users\User\AppData\Roaming\npm-cache\node-sass\4.5.3\win32-ia32-48_binding.node
node-sass@4.5.3 安装后 C:\crepe\node_modules\node-sass 节点脚本/build.js 构建:C:\Program Files (x86)\nodejs\node.exe C:\crepe\node_modules\node-gyp\bin\node-gyp.js 重建 --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files (x86)\\nodejs\\node.exe',
gyp verb cli 'C:\\crepe\\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 node-gyp@3.8.0
gyp info using node@6.11.1 | win32 | ia32
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:\crepe\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\crepe\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\crepe\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\crepe\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\crepe\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\crepe\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed python2 Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\crepe\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\crepe\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\crepe\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\crepe\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\crepe\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\crepe\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (C:\\crepe\\node_modules\\which\\which.js:13:12)\n at F (C:\\crepe\\node_modules\\which\\which.js:68:19)\n at E (C:\\crepe\\node_modules\\which\\which.js:80:29)\n at C:\\crepe\\node_modules\\which\\which.js:89:16\n at C:\\crepe\\node_modules\\isexe\\index.js:42:5\n at C:\\crepe\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:123:15)',
gyp verb `which` failed code: 'ENOENT'
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 (C:\crepe\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\crepe\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\crepe\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\crepe\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\crepe\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\crepe\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed python Error: not found: python
gyp verb `which` failed at getNotFoundError (C:\crepe\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\crepe\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\crepe\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\crepe\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\crepe\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\crepe\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed at getNotFoundError (C:\crepe\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\crepe\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\crepe\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\crepe\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\crepe\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\crepe\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (C:\\crepe\\node_modules\\which\\which.js:13:12)\n at F (C:\\crepe\\node_modules\\which\\which.js:68:19)\n at E (C:\\crepe\\node_modules\\which\\which.js:80:29)\n at C:\\crepe\\node_modules\\which\\which.js:89:16\n at C:\\crepe\\node_modules\\isexe\\index.js:42:5\n at C:\\crepe\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:123:15)',
gyp verb `which` failed code: 'ENOENT'
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 (C:\crepe\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\crepe\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\crepe\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\crepe\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\crepe\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\crepe\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed python Error: not found: python
gyp verb `which` failed at getNotFoundError (C:\crepe\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\crepe\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\crepe\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\crepe\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\crepe\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\crepe\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed stack: 'Error: not found: python\n at getNotFoundError (C:\\crepe\\node_modules\\which\\which.js:13:12)\n at F (C:\\crepe\\node_modules\\which\\which.js:68:19)\n at E (C:\\crepe\\node_modules\\which\\which.js:80:29)\n at C:\\crepe\\node_modules\\which\\which.js:89:16\n at C:\\crepe\\node_modules\\isexe\\index.js:42:5\n at C:\\crepe\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:123:15)',
gyp verb `which` failed code: 'ENOENT'
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 Object.failNoPython (C:\crepe\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at Object.<anonymous> (C:\crepe\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at C:\crepe\node_modules\graceful-fs\polyfills.js:282:31
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\crepe\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\crepe\node_modules\node-sass
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
node-sass@4.5.3 C:\crepe\node_modules\node-sass
我正在使用 Ionic 3.9.2、Angular 5.0.0 和 Node JS 6.11.1 32 位。我该怎么办?
【问题讨论】:
【参考方案1】:根据这个documentation,您应该安装Node.js LTS(目前是v10.15.3)而不是v6.11.1。并让npm
保持最新状态
$ npm i -g npm
更新Node.js
后,在本地重新安装node_modules
。您最好删除 ex-node_modules
文件夹和 package-lock.json
文件。
希望对您有所帮助。
【讨论】:
确实,我重建了node_modules
,它确实有效。谢谢!以上是关于Ionic 3 项目中的 Node JS 和 SASS 不兼容问题的主要内容,如果未能解决你的问题,请参考以下文章
Ionic 2.0.0-beta.24 如何在没有 ionic.config.js 的情况下导入 node_module css 文件