Coder Social home page Coder Social logo

Comments (13)

chentsulin avatar chentsulin commented on April 28, 2024

Sorry for incorrect webpack build target setting. I set it to atom now.

import fs from 'fs'

will work after this fix been merged.

from electron-react-boilerplate.

chentsulin avatar chentsulin commented on April 28, 2024

Any other issues and issue reopen will be welcome.

from electron-react-boilerplate.

0x80 avatar 0x80 commented on April 28, 2024

Hi, thanks for the quick fix. However I'm now running into a problem with webpack when it tries to include serialport. The first part of the warnings are below. It seems like webpack is trying to load every file in the module folder.

WARNING in ./~/serialport/serialport.js
Critical dependencies:
14:24-45 the request of a dependency is an expression
 @ ./~/serialport/serialport.js 14:24-45

WARNING in ./~/serialport/~/node-pre-gyp/lib/pre-binding.js
Critical dependencies:
19:22-48 the request of a dependency is an expression
 @ ./~/serialport/~/node-pre-gyp/lib/pre-binding.js 19:22-48

WARNING in ./~/serialport/~/node-pre-gyp/lib/util/versioning.js
Critical dependencies:
15:20-67 the request of a dependency is an expression
 @ ./~/serialport/~/node-pre-gyp/lib/util/versioning.js 15:20-67

WARNING in ./~/serialport/~/node-pre-gyp/lib/util/compile.js
Module not found: Error: Cannot resolve module 'node-gyp' in /Users/me/Development/myapp/node_modules/serialport/node_modules/node-pre-gyp/lib/util
 @ ./~/serialport/~/node-pre-gyp/lib/util/compile.js 29:28-55

WARNING in ./~/serialport/~/node-pre-gyp/lib/util/compile.js
Module not found: Error: Cannot resolve module 'npm' in /Users/me/Development/myapp/node_modules/serialport/node_modules/node-pre-gyp/lib/util
 @ ./~/serialport/~/node-pre-gyp/lib/util/compile.js 39:27-49

WARNING in ./~/serialport/AUTHORS
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/AUTHORS Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| # The main authors of this library
| 
| Chris Williams <[email protected]>
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/LICENSE
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/LICENSE Line 1: Unexpected number
You may need an appropriate loader to handle this file type.
| Copyright 2010, 2011, 2012 Christopher Williams. All rights reserved.
| Permission is hereby granted, free of charge, to any person obtaining a copy
| of this software and associated documentation files (the "Software"), to
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/Makefile
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/Makefile Line 1: Unexpected token =
You may need an appropriate loader to handle this file type.
| VERSION := $(shell node -e "console.log(require('./package.json').version)")
| 
| .PHONY: default release
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/appveyor.yml
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/appveyor.yml Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| # environment variables
| environment:
|   node_pre_gyp_secretAccessKey:
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/arduinoTest/arduinoEcho/arduinoEcho.ino
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/arduinoTest/arduinoEcho/arduinoEcho.ino Line 1: Unexpected identifier
You may need an appropriate loader to handle this file type.
| const int ledPin = 11;
| 
| void setup() {
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/bin/serialportList.js
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/bin/serialportList.js Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| #!/usr/bin/env node
| 
| var serialport = require('../');
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/bin/serialportTerminal.js
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/bin/serialportTerminal.js Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| #!/usr/bin/env node
| 
| var SerialPort = require('../').SerialPort;
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/binding.gyp
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/binding.gyp Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
|   'targets': [
|     {
|       'target_name': 'serialport',
 @ ./~/serialport ^\.\/.*$

WARNING in ./~/serialport/build/Makefile
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/build/Makefile Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| # We borrow heavily from the kernel build setup, though we are simpler since
| # we don't have Kconfig tweaking settings on us.
| 
 @ ./~/serialport ^\.\/.*$

And then there are these errors starting with:

ERROR in ./~/serialport/~/node-pre-gyp/lib/node-pre-gyp.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../package in /Users/me/Development/myapp/node_modules/serialport/node_modules/node-pre-gyp/lib
 @ ./~/serialport/~/node-pre-gyp/lib/node-pre-gyp.js 60:16-37

ERROR in ./~/serialport/arduinoTest/stress.js
Module not found: Error: Cannot resolve module 'colors' in /Users/me/Development/myapp/node_modules/serialport/arduinoTest
 @ ./~/serialport/arduinoTest/stress.js 8:13-30

ERROR in ./~/serialport/arduinoTest/stress.js
Module not found: Error: Cannot resolve module 'memwatch' in /Users/me/Development/myapp/node_modules/serialport/arduinoTest
 @ ./~/serialport/arduinoTest/stress.js 10:15-34

ERROR in ./~/serialport/test/parsers.js
Module not found: Error: Cannot resolve module 'sinon-chai' in /Users/me/Development/myapp/node_modules/serialport/test
 @ ./~/serialport/test/parsers.js 5:16-37

ERROR in ./~/serialport/test_mocks/linux-hardware.js
Module not found: Error: Cannot resolve module 'sandboxed-module' in /Users/me/Development/myapp/node_modules/serialport/test_mocks
 @ ./~/serialport/test_mocks/linux-hardware.js 144:22-49

ERROR in ./~/serialport/~/node-pre-gyp/~/rc/index.js
Module parse failed: /Users/me/Development/myapp/node_modules/serialport/node_modules/node-pre-gyp/node_modules/rc/index.js Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| #! /usr/bin/env node
| var cc   = require('./lib/utils')
| var join = require('path').join
 @ ./~/serialport/~/node-pre-gyp/lib/info.js 11:13-26

ERROR in ./~/serialport/~/node-pre-gyp/lib/info.js
Module not found: Error: Cannot resolve module 'aws-sdk' in /Users/me/Development/myapp/node_modules/serialport/node_modules/node-pre-gyp/lib
 @ ./~/serialport/~/node-pre-gyp/lib/info.js 14:14-32

ERROR in ./~/serialport/~/node-pre-gyp/lib/publish.js
Module not found: Error: Cannot resolve module 'aws-sdk' in /Users/me/Development/myapp/node_modules/serialport/node_modules/node-pre-gyp/lib
 @ ./~/serialport/~/node-pre-gyp/lib/publish.js 17:14-32

from electron-react-boilerplate.

0x80 avatar 0x80 commented on April 28, 2024

Nevermind. I am also seeing these errors when I use webpack on just a simple file which includes node-serialport. So it has nothing to do with your specific webpack configuration or the electron environment...

from electron-react-boilerplate.

chentsulin avatar chentsulin commented on April 28, 2024

I should add .json and .node to resolve.extensions for imitating node require.

And some errors about Cannot resolve module ... It looks like devDependencies are not installed.

from electron-react-boilerplate.

0x80 avatar 0x80 commented on April 28, 2024

Ah wonderful! I'm glad you have a clue :)

Now I think about it, I guess it's pretty weird to try and pack a natively compiled module into static assets. I guess that's what webpack tries to do now.

from electron-react-boilerplate.

chentsulin avatar chentsulin commented on April 28, 2024

Maybe we should find some webpack config, loader, plugin...whatever to handle this expression dependency...

var PACKAGE_JSON = path.join(__dirname, 'package.json');
var binding_path = binary.find(path.resolve(PACKAGE_JSON));
var SerialPortBinding = require(binding_path);

from electron-react-boilerplate.

0x80 avatar 0x80 commented on April 28, 2024

According to this webpack/webpack#1040 you can use node-loader. Not sure what other problem we are trying to solve :) I am currently figuring out how to compile serialport for iojs since there is also an issue there it seems...

from electron-react-boilerplate.

chentsulin avatar chentsulin commented on April 28, 2024

webpack/webpack#839

Add node_modules to externals will fix some of issues.

from electron-react-boilerplate.

0x80 avatar 0x80 commented on April 28, 2024

Thanks, I think we're getting there :) Here's a nice article covering that plus more interesting things

http://jlongster.com/Backend-Apps-with-Webpack--Part-I

from electron-react-boilerplate.

0x80 avatar 0x80 commented on April 28, 2024

I managed to get serialport working with these changes. It looks like you've already committed similar ones to the develop branche so I will check that soon.

from electron-react-boilerplate.

chentsulin avatar chentsulin commented on April 28, 2024

Thanks for sharing a useful post. I also look into library-and-externals.

So many configs let me a little confused. haha

Now I can require('serialport') on develop branch with no webpack issues.

from electron-react-boilerplate.

kristianmandrup avatar kristianmandrup commented on April 28, 2024

I have a similar problem trying to use node canvas module via fabric.js

fabricjs/fabric.js#3115

from electron-react-boilerplate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.