k-l-lambda / stylegan-web

A web porting for NVlabs' StyleGAN.
160 stars 41 forks source link

Frontend Build Error - Because of fast-api.js #3

Closed BarisSari closed 3 years ago

BarisSari commented 3 years ago

Hello,

First of all, I'd like to thank you for this amazing repository! My friend and I are examining it in this fork: https://github.com/aiksir/stylegan-web

When I run this command to build the frontend: npm run-script build, I get the following error:

(forked-stylegan-web) baris@bariss-MacBook-Pro forked-stylegan-web % npm run-script build

> stylegan-web@2.0.0 build /Users/baris/Documents/PycharmProjects/forked-stylegan-web
> rollup -c rollup.config.js

./app/index.js → dist/index.bundle.js...
created dist/index.bundle.js in 880ms

./app/projector.js → dist/projector.bundle.js...
[!] Error: 'import' and 'export' may only appear at the top level
node_modules/face-api.js/build/es6/env/isNodejs.js (1:0)
1: export function isNodejs() {
   ^
2:     return typeof global === 'object'
3:         && typeof require === 'function'
Error: 'import' and 'export' may only appear at the top level
    at error (/Users/baris/Documents/PycharmProjects/forked-stylegan-web/node_modules/rollup/dist/shared/node-entry.js:5400:30)
    at Module.error (/Users/baris/Documents/PycharmProjects/forked-stylegan-web/node_modules/rollup/dist/shared/node-entry.js:9824:16)
    at tryParse (/Users/baris/Documents/PycharmProjects/forked-stylegan-web/node_modules/rollup/dist/shared/node-entry.js:9717:23)
    at Module.setSource (/Users/baris/Documents/PycharmProjects/forked-stylegan-web/node_modules/rollup/dist/shared/node-entry.js:10080:33)
    at /Users/baris/Documents/PycharmProjects/forked-stylegan-web/node_modules/rollup/dist/shared/node-entry.js:12366:20
    at async Promise.all (index 4)
    at async Promise.all (index 6)
    at async Promise.all (index 2)
    at async Promise.all (index 0)
    at async Promise.all (index 1)
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async Promise.all (index 0)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! stylegan-web@2.0.0 build: `rollup -c rollup.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the stylegan-web@2.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/baris/.npm/_logs/2020-10-15T10_02_32_356Z-debug.log

I have made a quick search on the internet but I couldn't figure it out because I'm not much familiar with Vue. Are you aware of this issue?

k-l-lambda commented 3 years ago

It seems a bug with @rollup/plugin-commonjs ( reference ). Open file in your [project root]/node_modules/@rollup/plugin-commonjs/package.json, check the version number.

BarisSari commented 3 years ago

I downgraded plugin-common.js to 11.0.2 and yes, it's working now. Thanks the help, I'm closing the issue.