iT邦幫忙

0

有關truffle跟npm安裝的問題~

  • 分享至 

  • xImage

大家好~
第一次提問,剛學習不久,請多指教~
先感謝大家!!

想問我在github https://github.com/rajivjc/clinicaltrials-on-blockchain
下載並安裝~
在建置環境遇到兩個問題:

  1. 網站說明最後要打:truffle serve -p 8081
    打完顯示:
    truffle serve is not a valid truffle command. Please see truffle help for available commands.
    是不是現在沒有truffle serve指令了?
    因為我npm run dev也沒有成功(找不到dev,npm安裝還有以下第二個問題)
    想問有其他替代指令嗎?

  2. npm安裝出現以下錯誤,怎麼處理好...

npm ERR! code 1
npm ERR! path C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli 'C:\Program Files\nodejs\node.exe',
npm ERR! gyp verb cli 'C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\node-gyp\bin\node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@18.15.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb which failed Error: not found: python2
npm ERR! gyp verb which failed at getNotFoundError (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:13:12)
npm ERR! gyp verb which failed at F (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:68:19)
npm ERR! gyp verb which failed at E (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:80:29)
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:89:16
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\index.js:42:5
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb which failed at FSReqCallback.oncomplete (node:fs:208:21)
npm ERR! gyp verb which failed python2 Error: not found: python2
npm ERR! gyp verb which failed at getNotFoundError (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:13:12)
npm ERR! gyp verb which failed at F (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:68:19)
npm ERR! gyp verb which failed at E (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:80:29)
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:89:16
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\index.js:42:5
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb which failed at FSReqCallback.oncomplete (node:fs:208:21) {
npm ERR! gyp verb which failed code: 'ENOENT'
npm ERR! gyp verb which failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb which failed Error: not found: python
npm ERR! gyp verb which failed at getNotFoundError (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:13:12)
npm ERR! gyp verb which failed at F (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:68:19)
npm ERR! gyp verb which failed at E (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:80:29)
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:89:16
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\index.js:42:5
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb which failed at FSReqCallback.oncomplete (node:fs:208:21)
npm ERR! gyp verb which failed python Error: not found: python
npm ERR! gyp verb which failed at getNotFoundError (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:13:12)
npm ERR! gyp verb which failed at F (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:68:19)
npm ERR! gyp verb which failed at E (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:80:29)
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\which\which.js:89:16
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\index.js:42:5
npm ERR! gyp verb which failed at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb which failed at FSReqCallback.oncomplete (node:fs:208:21) {
npm ERR! gyp verb which failed code: 'ENOENT'
npm ERR! gyp verb which failed }
npm ERR! gyp verb could not find "python". checking python launcher
npm ERR! gyp verb could not find "python". guessing location
npm ERR! gyp verb ensuring that file exists: C:\Python27\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack at PythonFinder.failNoPython (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack at PythonFinder. (C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack at C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\graceful-fs\polyfills.js:282:31
npm ERR! gyp ERR! stack at FSReqCallback.oncomplete (node:fs:208:21)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd C:\Users\Vivobook\Downloads\clinicaltrials-on-blockchain-master\node_modules\node-sass
npm ERR! gyp ERR! node -v v18.15.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in: C:\Users\Vivobook\AppData\Local\npm-cache_logs\2023-04-11T11_09_56_523Z-debug-0.log

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

1
JamesDoge
iT邦高手 1 級 ‧ 2023-04-12 13:26:31
最佳解答

1.網站說明最後要打:truffle serve -p 8081
打完顯示:
truffle serve is not a valid truffle command. Please see truffle help for available commands.
是不是現在沒有truffle serve指令了?
因為我npm run dev也沒有成功(找不到dev,npm安裝還有以下第二個問題)
想問有其他替代指令嗎?

truffle serve 指令已被移除。你應該使用其他的 HTTP 伺服器來替代它。這裡是一個使用 lite-server 的例子:

1.在專案根目錄中,安裝 lite-server:

npm install lite-server --save-dev

2.在 package.json 中,將以下內容添加到 scripts 區塊:

"scripts": {
  "dev": "lite-server"
},

3.執行以下命令:

npm run dev

2.npm安裝出現以下錯誤,怎麼處理好...

你的環境中缺少 Python
你可以在官方網站下載
https://www.python.org/downloads/release/python-2718/

我要發表回答

立即登入回答