今天把Ionic1版本升級到了Ionic2,在命令行進入創建項目路徑後,運行
ionic start MyIonic2Project tutorial --v2
命令執行後,報如下錯誤
Installing npm packages...
Error with start undefined
Error Initializing app: There was an error with the spawned command: npminstall
There was an error with the spawned command: npminstall
Caught exception:
undefined
從github查到是因爲node和npm版本低了,解決方法如下:
1.升級node
win下直接官網下載最新安裝包 https://nodejs.org/en/(卸載當前node,安裝最新版node)
OS X 下運行命令
npm install -g n
2.升級npm
upgrade npm
3. 註冊表重新註冊 set new registry
npm set registry http://registry.npmjs.org
npm install -g cordova升級完成後,在命令行可查看版本號
重新創建ionic2的項目就可以了:
ionic start MyIonic2Project tutorial --v2
創建成功後,執行命令更新node_modules內所有包:
cnpm install
更新完成後,運行項目:
ionic serve