Truffle: 3.3.0 Update "fsevents is not a constructor" when running truffle serve

Created on 28 Jun 2017  Â·  23Comments  Â·  Source: trufflesuite/truffle

After updating to truffle 3.3.0, I get the following error when running 'truffle serve' during the building truffle frontend app tutorial http://truffleframework.com/tutorials/building-testing-frontend-app-truffle-3:

Issue

/Users/cameronvoell/.npm-packages/lib/node_modules/truffle/build/cli.bundled.js:123830
return (new fsevents(path)).on('fsevent', callback).start();
^
TypeError: fsevents is not a constructor
at createFSEventsInstance (/Users/cameronvoell/.npm-packages/lib/node_modules/truffle/build/cli.bundled.js:123830:11)
at setFSEventsListener (/Users/cameronvoell/.npm-packages/lib/node_modules/truffle/build/cli.bundled.js:123884:16)
at FSWatcher.FsEventsHandler._watchWithFsEvents (/Users/cameronvoell/.npm-packages/lib/node_modules/truffle/build/cli.bundled.js:124048:16)
at FSWatcher. (/Users/cameronvoell/.npm-packages/lib/node_modules/truffle/build/cli.bundled.js:124182:25)
at LOOP (fs.js:1758:14)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Camerons-MacBook-Air:test cameronvoell$ node version
module.js:471

throw err;

I reproduced the truffle serve fail on Ubuntu 16.04 and Mac OS El Capitan 10.11 with truffle version 3.3.0 while going through this demo http://truffleframework.com/tutorials/building-testing-frontend-app-truffle-3.

Expected Behavior

When I return to truffle version 3.2.2, the problem does not exist on OSX or Ubuntu

Environment

  • Operating System: Ubuntu 16.04 and Mac OS El Capitan 10.11
  • Truffle version: 3.3.0
  • Ethereum client: testrpc
  • node version:6.11.1
  • npm version: 3.10.10

Most helpful comment

From #448: Workaround would be to run npm run dev instead of truffle serve. Works for me on macOS 10.12.6.

All 23 comments

I see the same on osx 10.12.5 and ubuntu 16.04.2

$ truffle serve
Serving static assets in ./build on port 8080...
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:123830
  return (new fsevents(path)).on('fsevent', callback).start();
          ^

TypeError: fsevents is not a constructor
    at createFSEventsInstance (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:123830:11)
    at setFSEventsListener (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:123884:16)
    at FSWatcher.FsEventsHandler._watchWithFsEvents (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:124048:16)
    at FSWatcher.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:124182:25)
    at LOOP (fs.js:1615:14)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

And fsevents is installed:

npm i fsevents

> [email protected] install /Users/rsb/src/mozilla/truftest/node_modules/fsevents
> node install

[fsevents] Success: "/Users/rsb/src/mozilla/truftest/node_modules/fsevents/lib/binding/Release/node-v51-darwin-x64/fse.node" is installed via remote
[email protected] /Users/rsb/src/mozilla/truftest
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected] 

node version:

$ node --version
v7.2.0

Same here:

Operating System: Mac OS 10.9
Truffle version: 3.2.8
Ethereum client: testrpc
node version:6.11.0
npm version: 3.10.10

`Serving static assets in ./build on port 8080...
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:119780
return (new fsevents(path)).on('fsevent', callback).start();
^

TypeError: fsevents is not a constructor
at createFSEventsInstance (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:119780:11)
at setFSEventsListener (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:119834:16)
at FSWatcher.FsEventsHandler._watchWithFsEvents (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:119998:16)
at FSWatcher. (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:120132:25)
at LOOP (fs.js:1773:14)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)`

From #448: Workaround would be to run npm run dev instead of truffle serve. Works for me on macOS 10.12.6.

Same here:

Operating System: Mac OS 10.12.5
Truffle version: 3.3.1
Ethereum client: testrpc
node version:8.1.3
npm version: 5.0.3

Serving static assets in ./build on port 8080...
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:123804
return (new fsevents(path)).on('fsevent', callback).start();
^

TypeError: fsevents is not a constructor
at createFSEventsInstance (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:123804:11)
at setFSEventsListener (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:123858:16)
at FSWatcher.FsEventsHandler._watchWithFsEvents (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:124022:16)
at FSWatcher. (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:124156:25)
at gotStat (fs.js:1785:21)
at FSReqWrap.oncomplete (fs.js:152:21)

Same here. Any fix or workaround for this?

I tried npm run dev but there is a package.json missing.

@BuiltwithCaffeine solve it, try this: truffle init webpack

@samuelmantou thanks a lot.It's work.

@BuiltwithCaffeine Thank you worked for me..

Same on windows (10):

truffle build failed too, so I used truffle compile, I don't know what the difference is as I'm still learning.

$ truffle serve

Serving static assets in .\build on port 8080...
C:Users\DavidAppData\Roaming\npmnode_modules\truffle\build\cli.bundled.js:124978
return (new fsevents(path)).on('fsevent', callback).start();
^

TypeError: fsevents is not a constructor
at createFSEventsInstance (C:Users\DavidAppData\Roaming\npmnode_modules\truffle\build\cli.bundled.js:124978:11)
at setFSEventsListener (C:Users\DavidAppData\Roaming\npmnode_modules\truffle\build\cli.bundled.js:125032:16)
at FSWatcher.FsEventsHandler._watchWithFsEvents (C:Users\DavidAppData\Roaming\npmnode_modules\truffle\build\cli.bundled.js:125196:16)
at FSWatcher. (C:Users\DavidAppData\Roaming\npmnode_modules\truffle\build\cli.bundled.js:125330:25)
at LOOP (fs.js:1755:14)
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)

@samuelmantou much thanks, this worked.

This is a duplicate of #448. Closing for housekeeping.

@tcoulter maybe change the title of #448 for those of us who run into this problem? It's clearly not limited to non-mac platforms

@samuelmantou for me this worked : truffle unbox webpack

truffle init webpack
Error: truffle init no longer accepts a project template name as an argument.

truffle init webpack
Error: truffle init no longer accepts a project template name as an argument.

truffle init webpack
Error: truffle init no longer accepts a project template name as an argument.

^ I'm having the same issue as @FabiolaBusch @Gandalf-Pl @cmaliwal

This issue is resolved.
Need to use truffle unbox webpack instead of truffle init webpack.

@Gandalf-Pl @FabiolaBusch @JimiPedros

@cmaliwal It's not working.
truffle unbox webpack
this occurs below error.
Compilation warnings encountered:

/F/ETHERIUM/my-money/contracts/MetaCoin.sol:15:2: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
function MetaCoin() public {
^ (Relevant source part starts here and spans across multiple lines).
,/F/ETHERIUM/my-money/contracts/Migrations.sol:11:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
function Migrations() public {
^ (Relevant source part starts here and spans across multiple lines).
,/F/ETHERIUM/my-money/contracts/MetaCoin.sol:23:3: Warning: Invoking events without "emit" prefix is deprecated.
Transfer(msg.sender, receiver, amount);
^------------------------------------^

Writing artifacts to .\build\contracts

Could not connect to your Ethereum client. Please check that your Ethereum client:
- is running
- is accepting RPC connections (i.e., "--rpc" option is used in geth)
- is accessible over the network
- is properly configured in your Truffle configuration file (truffle.js)

F:ETHERIUM\my-money>truffle.cmd serve

Serving static assets in .\build on port 8080...
TypeError: fsevents is not a constructor
at createFSEventsInstance (C:Users\edisoAppData\Roaming\npmnode_modules\truffle\build\webpack:\~\chokidar\lib\fsevents-handler.js:26:1)
at setFSEventsListener (C:Users\edisoAppData\Roaming\npmnode_modules\truffle\build\webpack:\~\chokidar\lib\fsevents-handler.js:80:1)
at FSWatcher.FsEventsHandler._watchWithFsEvents (C:Users\edisoAppData\Roaming\npmnode_modules\truffle\build\webpack:\~\chokidar\lib\fsevents-handler.js:244:1)
at FSWatcher. (C:Users\edisoAppData\Roaming\npmnode_modules\truffle\build\webpack:\~\chokidar\lib\fsevents-handler.js:378:1)
at LOOP (fs.js:1773:14)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)

Disable the FsEvents when not used:

C:\Users\ediso\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js

// if (!FsEventsHandler.canUse())

opts.useFsEvents = false;

Steps:

truffle compile && truffle build && truffle migrate && truffle serve

The same issue for running truffle serve installed on level of project (not globally):

Docker

  • Based on Image:
    node:8.0.0-alpine
  • Truffle Version:
    Truffle v4.1.13 (core: 4.1.13)
    Solidity v0.4.24 (solc-js)

OS X

  • System Version:
    High Sierra 10.13.3 (17D47)
  • Node Versions:
    v8.11.3
  • Truffle Version:
    Truffle v4.1.13 (core: 4.1.13)
    Solidity v0.4.24 (solc-js)

Also, I could not manage to use webpack box running truffle unbox webpack I get (on mentioned docker env):

Downloading...
Unpacking...
Setting up...
Error: stdout maxBuffer exceeded
at Socket.onChildStdout (child_process.js:328:14)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:246:13)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:597:20)

Issue has been already spotted for other box:
https://github.com/truffle-box/react-box/issues/56

@tcoulter can you please address this?

same problem not solve...........
truffle serveServing static assets in ./build on port 8080...

/usr/local/lib/node_modules/truffle/build/webpack:/~/chokidar/lib/fsevents-handler.js:26
return (new fsevents(path)).on('fsevent', callback).start();
^
TypeError: fsevents is not a constructor
at createFSEventsInstance (/usr/local/lib/node_modules/truffle/build/webpack:/~/chokidar/lib/fsevents-handler.js:26:1)
at setFSEventsListener (/usr/local/lib/node_modules/truffle/build/webpack:/~/chokidar/lib/fsevents-handler.js:80:1)
at FSWatcher.FsEventsHandler._watchWithFsEvents (/usr/local/lib/node_modules/truffle/build/webpack:/~/chokidar/lib/fsevents-handler.js:244:1)
at FSWatcher. (/usr/local/lib/node_modules/truffle/build/webpack:/~/chokidar/lib/fsevents-handler.js:378:1)
at gotStat (fs.js:1783:21)
at FSReqWrap.oncomplete (fs.js:152:21)

truffle unboxwebpack
Downloading...
Error: Something already exists at the destination. truffle init and truffle unbox must be executed in an empty folder. Stopping to prevent overwriting data.
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-box/lib/utils/unbox.js:22:1
at
at process._tickCallback (internal/process/next_tick.js:188:7)
at Function.Module.runMain (module.js:695:11)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3

Was this page helpful?
0 / 5 - 0 ratings