NREL / floorspace.js

Other
66 stars 35 forks source link

Problem with webpack file-loader while npm run dev: emitFile is required from module system #337

Closed Jopenergy closed 5 years ago

Jopenergy commented 5 years ago

Hi,

I tried to launch Floorspace after forking the project locally and in an empty docker container (node 11.1.0, npm 6.4.1).

In both cases the installation (npm install) went well even if I got some little warnings.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 1562 packages from 2001 contributors and audited 9523 packages in 370.346s
found 8 vulnerabilities (2 low, 4 moderate, 2 high)

But I encountered the same issue in both cases while trying to run (npm run dev):

> node build/dev-server.js

Listening at http://localhost:8080

(node:317) UnhandledPromiseRejectionWarning: Error: Exited with code 3
    at ChildProcess.<anonymous> (/app/floorspace/node_modules/opn/index.js:83:13)
    at Object.onceWrapper (events.js:273:13)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:387:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:611:12)
(node:317) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:317) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
webpack built c484dfe57fa3aa4b4ff3 in 29517ms
Hash: c484dfe57fa3aa4b4ff3
Version: webpack 1.15.0
Time: 29517ms
 Asset     Size  Chunks       Chunk Names
app.js  13.5 MB       0       app

ERROR in ./~/element-ui/lib/theme-chalk/fonts/element-icons.ttf
Module build failed: Error: emitFile is required from module system
    at Object.module.exports (/app/floorspace/node_modules/file-loader/index.js:9:27)
    at Object.loader (/app/floorspace/node_modules/url-loader/dist/index.js:76:19)
 @ ./~/css-loader!./~/element-ui/lib/theme-chalk/index.css 6:396-432
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  1.47 MB       0       
webpack: Failed to compile.

People recommend to turn emitFile to false in the webpack config to solve the problem (https://github.com/webpack-contrib/file-loader/issues/2). So I tried in "/build/webpack.base.conf.js" but it had no effect.

Thank you in advance for your help,

CassandraGoose commented 5 years ago

Howdy! @Jopenergy, would it be possible to see the Dockerfile you used when running this in an empty container? I'm trying to reproduce the issue. Thanks so much!

bgschiller commented 5 years ago

@CassandraGoose and I were able to get floorspace running without too much trouble using the following Dockerfile, mostly copied from the vuejs cookbook:

FROM node:11.1.0

# install simple http server for serving static content
RUN npm install -g http-server

# make the 'app' folder the current working directory
WORKDIR /app

# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./

# install project dependencies
RUN npm install

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .

# build app for production with minification
RUN npm run build

EXPOSE 8080
CMD [ "http-server", "dist" ]

Does this work for what you're trying to do? It looks like you were trying to run the dev server from inside docker, but I'd recommend a local setup for the dev server.

Jopenergy commented 5 years ago

As far as I'm concerned, I had actually used the node:latest image with a shared volume and simply had run "npm install". I don't really understand what went wrong... But anyway, it's working great with this Dockerfile ! Thank you!!