Ich habe versucht, das Truffle Framework über npm auf Elementary OS (Ubuntu-Distribution) zu installieren und zu verwenden. Es gab keine offensichtlichen Probleme mit der Installation, aber wenn ich einen Befehl ausführe, z. B. "truffle init" oder "truffle unbox metacoin", erhalte ich den Fehler:
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:64601
!function(e,t){ true?module.exports=t():"function"==typeof define&&define.amd?define("ganache",[],t):"object"==typeof exports?exports.ganache=t():e.ganache=t()}(global,function(){return function(e){var t={};function a(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,a),r.l=!0,r.exports}return a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},a.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a.w={},a(a.s=1222)}([function(e,t,a){try{var n=a(1);if("function"!=typeof n.inherits)throw"";e.exports=n.inherits}catch(t){e.exports=a(1208)}},function(e,t){e.exports=__webpack_require__(3)},function(e,t){e.exports=__webpack_require__(0)},function(e,t
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
Ich nehme an, dass dies eine Art Kompatibilitätsproblem mit ES5/6 ist. Aber ich bin mir nicht sicher, warum dies bei einer Neuinstallation passieren würde.
apt install npm
hat bei mir nie richtig funktioniert.
Entfernen Sie es und installieren Sie es wie hier beschrieben https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
npm uninstall -g truffle
apt purge npm
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
npm i -g truffle
Samuel Barnes