Ionic3项目创建

羊舌诚
2023-12-01

Ionic3项目创建

本地环境:
$ cordova -v9.0.0 (cordova-lib@9.0.1)
$ ionic -v3.12.0
$ npm -v6.10.3
$ node -v12.9.1

步骤
一:进入项目目录
二:ionic start 项目名 --no-deps
【–no-deps是跳过npm安装依赖,因为翻不了墙 先跳过之后淘宝镜像安装】
后续需要选择tabs 以及是否连接git
三:cd 进入项目根目录
四:cnpm install 【安装依赖】
此处报错:
1 error generated.
make: *** [Release/obj.target/binding/src/create_string.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Applications/IntelliJ IDEA.app/practice_vue/未命名文件夹 2/ionic3/node_modules/_node-gyp@3.8.0@node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:209:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command “/usr/local/Cellar/node/12.9.1/bin/node” “/Applications/IntelliJ IDEA.app/practice_vue/未命名文件夹 2/ionic3/node_modules/_node-gyp@3.8.0@node-gyp/bin/node-gyp.js” “rebuild” “–verbose” “–libsass_ext=” “–libsass_cflags=” “–libsass_ldflags=” “–libsass_library=”
gyp ERR! cwd /Applications/IntelliJ IDEA.app/practice_vue/未命名文件夹 2/ionic3/node_modules/_node-sass@4.5.3@node-sass
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
[npminstall:runscript:error] @ionic/app-scripts@3.1.0 › node-sass@~4.5.3 scripts.postinstall run “node scripts/build.js” error: Error [RunScriptError]: Run “sh -c node scripts/build.js” error, exit code 1
at ChildProcess. (/usr/local/lib/node_modules/cnpm/node_modules/runscript/index.js:96:21)
at ChildProcess.emit (events.js:209:13)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
name: ‘RunScriptError’,
stdio: [Object]
}
✖ Install fail! RunScriptError: post install error, please remove node_modules before retry!
Run “sh -c node scripts/build.js” error, exit code 1
RunScriptError: Run “sh -c node scripts/build.js” error, exit code 1
at ChildProcess. (/usr/local/lib/node_modules/cnpm/node_modules/runscript/index.js:96:21)
at ChildProcess.emit (events.js:209:13)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
npminstall version: 3.23.0
npminstall args: /usr/local/Cellar/node/12.9.1/bin/node /usr/local/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js --fix-bug-versions --china --userconfig=/Users/limingyu/.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=https://r.npm.taobao.org
解决方法:1、删除项目node_modules下的node-sass@~4.5.3或其他版本文件
2、终端输入 cnpm install node-sass@4.12
3、启动项目okk

解释参考:
I’m using OSX latest version(10.14.4 (18E226)) and node 12.
While using node-sass 4.11, I had g++ error(…/src/create_string.cpp:17:25: error: no matching constructor for initialization of ‘v8::String::Utf8Value’) while trying npm install, npm rebuild(link) which did not work.
I solved this by updating node-sass to 4.12(npm install node-sass), as the github issue on the node-sass says that support for node 12 is implemented in 4.12 version.

这是俺第一次通过外文网站解决bug 因为懒得看英文百度白天无果 果然学英语还是有用的…
附链接:https://stackoverflow.com/questions/55973930/yarn-node-sass-does-not-yet-support-my-current-environment

 类似资料: