Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run build #1036

Closed
SaraVieira opened this issue Jun 4, 2017 · 20 comments
Closed

Cannot run build #1036

SaraVieira opened this issue Jun 4, 2017 · 20 comments

Comments

@SaraVieira
Copy link

SaraVieira commented Jun 4, 2017

Hello,

Great boilerplate , I do get an error when trying to run the build:

Here is the stack trace:

[0] ERROR in ./~/fsevents/~/rc/index.js
[0] Module parse failed: /Users/saravieira/Desktop/electron-workshop/node_modules/fsevents/node_modules/rc/index.js Unexpected character '#' (1:0)
[0] You may need an appropriate loader to handle this file type.
[0] | #! /usr/bin/env node
[0] | var cc   = require('./lib/utils')
[0] | var join = require('path').join
[0]  @ ./~/fsevents/~/node-pre-gyp/lib/info.js 11:13-26
[0]  @ ./~/fsevents/~/node-pre-gyp/lib ^\.\/.*$
[0]  @ ./~/fsevents/~/node-pre-gyp/lib/node-pre-gyp.js
[0]  @ ./~/fsevents/fsevents.js
[0]  @ ./~/chokidar/lib/fsevents-handler.js
[0]  @ ./~/chokidar/index.js
[0]  @ ./~/electron-reload/main.js
[0]  @ ./app/main.dev.js
[0]  @ multi babel-polyfill ./app/main.dev
[0] 
[0] ERROR in unknown: Invalid number (230534:27)
[0] npm
[0]  ERR! code ELIFECYCLE
[0] npm ERR! errno 2
[0] npm ERR!
[0]  electron-workshop@1.0.2 build-main: `cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.main.prod.js --progress --profile --colors`
[0] npm ERR! Exit status 2
[0] npm ERR! 
[0] npm ERR!
[0]  Failed at the dagger@1.0.2 build-main script.
[0] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Has this happened to anyone ?
In dev this run awesome

@amilajack
Copy link
Member

amilajack commented Jun 4, 2017

Interesting. How did you install you dependencies? I would recommend using yarn and the latest version of node:

npm i -g yarn
rm -rf node_modules
yarn

Also did you make any changes to the boilerplate or did you start off with a fresh clone?

@SaraVieira
Copy link
Author

I have used yarn and I am using the latest version of node.

I made some changes, you can check the repo at:https://github.com/SaraVieira/Dagger

It may have been a newbie mistake

@amilajack
Copy link
Member

@SaraVieira Try doing a fresh clone of the boilerplate. If there its no issue with running npm run build/yarn build with the fresh clone, we know that the issue is with your fork. This helps narrow down the issue.

@crakjie
Copy link

crakjie commented Jun 12, 2017

@amilajack I have almost the same problem than @SaraVieira,
Do you have an idea to make this ERROR in unknown: Invalid number (76705:15) more verbose?

@amilajack
Copy link
Member

@SaraVieira try some of the solution here: webpack/webpack#4603 (comment)

@amilajack
Copy link
Member

@crakjie Are you getting an error that includes Unexpected character '#' ?

@crakjie
Copy link

crakjie commented Jun 12, 2017

I think the # problem in the first message is not related to ERROR in unknown: Invalid number (230534:27) In my case, the message come alone.

@amilajack
Copy link
Member

@crakjie what does your stacktrace look like?

@amilajack
Copy link
Member

@SaraVieira you can resolve this by adding fsevents to your externals in the base webpack config. If fsevents is required in the renderer process then move the dependency that requires it to ./app/package.json

@crakjie
Copy link

crakjie commented Jun 13, 2017

@amilajack In the log file I have the same stack trace than in #967, which just mean "something want wrong" I think.

@amilajack
Copy link
Member

After looking at this again, this most likely has to do with fsevents being a native module. There's two possible solutions to this:

  1. Add the shebang-loader to your webpack.config.base.js

  2. Add fsevents as an external webpack dependency. In webpack.config.base.js

export default {
  externals: [
    'fsevents',
    ...Object.keys(externals || {})
  ],
  // ...
}

@amilajack
Copy link
Member

Closing because I think this was addressed. Please let me know if you're still experiencing issues with this and I will gladly reopen the issue

@matthewcc
Copy link

matthewcc commented Oct 20, 2017

I was getting the cryptic Invalid number error and the above solutions did not help me, and I spent a large amount of time trying to fix it. A variety of (relatively old and abandoned) modules I was importing would trigger this error, and after digging into those modules own dependencies and importing them directly, the Invalid number error actually came with some useful information:

if (typeof mode === 'function' || typeof mode === 'undefined') {
    callback = mode;
    mode = 0777 & (~process.umask());
           ^
}

 if (!callback) {

This came from the module mkpath. It turns out this is a deprecated way of writing an octal number in node, and babel will only accept the es6 way of (using the example) 0o777. So, at least in my case this error ended up having nothing to do with this boilerplate (which is great, thank you!), and I was able to solve the issue by adding a loader to the base config: octal-number-loader

I realize this issue is closed, but I wanted to leave this here in case anyone else came across it, especially since this git issue is the top Google result for "ERROR in unknown: Invalid number".

@shhdharmen
Copy link

shhdharmen commented Nov 14, 2017

@matthewcc I tried with octal-number-loader, but still getting the same error. Any idea why? Below is my webpack.config.js file

var webpack = require('webpack');
const config = {
    entry: ['babel-polyfill', './src/main/index.js', ...],
    plugins: [
        new webpack.DefinePlugin({ "global.GENTLY": false })
    ],
    node: {
        __dirname: true,
    },
    resolve: {
        alias: {
            'inherits': 'inherits/inherits_browser.js',
            'superagent': 'superagent/lib/client',
            'emitter': 'component-emitter',
        }
    },
    module: {
        rules: [{
            test: /\.js$/,
            exclude: /(node_modules|bower_components)/,
            use: {
                loader: 'babel-loader',
                options: {
                    presets: ['@babel/preset-env']
                }
            }
        }, {
            test: /tar[\\\/].*\.js$/,
            loader: 'babel-loader!octal-number-loader'
        }]
    }
};

module.exports = config;

@iamblue
Copy link

iamblue commented Dec 12, 2017

same issue +1

@amilajack
Copy link
Member

@iamblue please share your stack trace

@chengmu
Copy link

chengmu commented Jan 8, 2018

@matthewcc save my day!!

ERROR in unknown: Invalid number; google to this issue, same module mkpath

@matthewcc
Copy link

matthewcc commented Jan 25, 2018

@shhdharmen sorry for the long delay I missed this. Hopefully, you found the answer.

I don't really know the ins and outs of webpack, but my own module setting looks like this:
{ test: /\.js$/, loader: 'octal-number-loader' }

You may not want/need to run it through babel. I also can only barely comprehend regex, but its possible your test is also filtering out the files you wanted to convert.

And actually the above setting eventually created a problem, in that it converts not just octal numbers, but anything it encounters inside a string that looks like an octal. So I am saving HTML gamepad ids for an arcade application for remembering which is player 1, which is player 2. But the stored id string contained what looked like octals (028e for example), and these were being converted, creating a mismatch. Ultimately, I chose to apply the octal loader just to the offending package:

{ test: /mkpath.js$/, loader: 'octal-number-loader' }

@albertotorresfoltyn
Copy link

same here... my stack

WARNING in ./node_modules/electron-debug/index.js
84:85-106 Critical dependency: the request of a dependency is an expression
@ ./node_modules/electron-debug/index.js
@ dll renderer

ERROR in ./node_modules/npm/bin/npm-cli.js
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
| #!/usr/bin/env node
| ;(function () { // wrapper in case we're in module_context mode
| // windows: running "npm blah" in this folder will invoke WSH, not node.
@ ./node_modules/npm/lib/npm.js 470:4-32
@ dll renderer
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! cmfl@0.13.2 build-dll: cross-env NODE_ENV=development node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.dev.dll.js --colors
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the cmfl@0.13.2 build-dll 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! C:\Users\Alberto\AppData\Roaming\npm-cache_logs\2018-04-26T16_10_50_220Z-debug.lognpm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! cmfl@0.13.2 postinstall: node -r babel-register internals/scripts/CheckNativeDep.js && npm run flow-typed && npm run build-dll && electron-builder install-app-deps && node node_modules/fbjs-scripts/node/check-dev-engines.js package.jsonnpm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the cmfl@0.13.2 postinstall 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! C:\Users\Alberto\AppData\Roaming\npm-cache_logs\2018-04-26T16_10_50_845Z-debug.log

@githoniel

This comment has been minimized.

@electron-react-boilerplate electron-react-boilerplate locked as resolved and limited conversation to collaborators Dec 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants