mjohnston / react-native-webpack-server

Build React Native apps with Webpack
MIT License
933 stars 84 forks source link

Not working! "not found in any of the roots" #133

Closed niftylettuce closed 8 years ago

niftylettuce commented 8 years ago
react-native packager ready...
[11:36:32 PM] <END>   Crawling File System (628ms)
[11:36:32 PM] <START> Building in-memory fs for JavaScript
[11:36:33 PM] <END>   Building in-memory fs for JavaScript (1189ms)
[11:36:33 PM] <START> Building in-memory fs for Assets
[11:36:34 PM] <END>   Building in-memory fs for Assets (817ms)
[11:36:34 PM] <START> Building Haste Map
[11:36:34 PM] <START> Building (deprecated) Asset Map
[11:36:34 PM] <END>   Building (deprecated) Asset Map (250ms)
[11:36:34 PM] <START> request:/index.ios.bundle?platform=ios&dev=true
[11:36:34 PM] <START> find dependencies
[11:36:34 PM] <END>   Building Haste Map (799ms)
[11:36:34 PM] <END>   Building Dependency Graph (3440ms)
undefined
{"message":"Cannot find entry file index.ios.js in any of the roots: [\"/Users/nexus/Public/project/Project\"]","name":"NotFoundError","type":"NotFoundError","status":404,"errors":[{}]}
[11:36:45 PM] <START> request:/index.ios.bundle?platform=ios&dev=true
[11:36:45 PM] <START> find dependencies
undefined
{"message":"Cannot find entry file index.ios.js in any of the roots: [\"/Users/nexus/Public/project/Project\"]","name":"NotFoundError","type":"NotFoundError","status":404,"errors":[{}]}

ugh, what has changed?! Why doesn't this work...

niftylettuce commented 8 years ago

I didn't change anything, i just did a fresh npm install and it stopped working

has something changed with webpack or this rnws package?

elliottsj commented 8 years ago

@niftylettuce Turns out the RN 0.13 local-cli/cli.js script behaves a bit differently than in RN 0.14 :expressionless:. Can you try out the rn-0.13-fix branch and let me know if it works?

niftylettuce commented 8 years ago

I'll just wait for a stable version, just using react native packager for now

jrm2k6 commented 8 years ago

I do have the same issue on a fresh RN (0.14.2) project.

My webpack config:

'use strict';

var fs = require('fs');
var path = require('path');
var webpack = require('webpack');

var config = {

  debug: true,

  devtool: 'source-map',

  entry: {
    'index.ios': ['./src/app.js'],
    'index.android': ['./src/app.js'],
  },

  output: {
    path: path.resolve(__dirname, 'build'),
    filename: '[name].js',
  },

  module: {
    loaders: [{
      test: /\.js$/,
      include: [
          path.resolve(__dirname, 'src')
      ],
      loader: 'babel',
      query: {
        stage: 0,
        plugins: []
      }
    }]
  },

  plugins: [],
};

// Hot loader
if (process.env.HOT) {
  config.devtool = 'eval'; // Speed up incremental builds
  config.entry['index.ios'].unshift('react-native-webpack-server/hot/entry');
  config.entry['index.ios'].unshift('webpack/hot/only-dev-server');
  config.entry['index.ios'].unshift('webpack-dev-server/client?http://localhost:8082');
  config.output.publicPath = 'http://localhost:8082/';
  config.plugins.unshift(new webpack.HotModuleReplacementPlugin());
  config.module.loaders[0].query.plugins.push('react-transform');
  config.module.loaders[0].query.extra = {
    'react-transform': [{
      target: 'react-transform-hmr',
      imports: ['react-native'],
      locals: ['module']
    }]
  };
}

// Production config
if (process.env.NODE_ENV === 'production') {
  config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin());
  config.plugins.push(new webpack.optimize.UglifyJsPlugin());
}

module.exports = config;

My package.json:

{
  "name": "AppCompanion",
  "version": "0.0.1",
  "private": true,
  "scripts": {
      "bundle": "rnws bundle",
      "start": "rnws start"
  },
  "dependencies": {
    "babel": "^5.8.23",
    "babel-core": "^5.8.24",
    "babel-loader": "^5.3.2",
    "react-native": "^0.14.2"
  },
  "devDependencies": {
    "babel-plugin-react-transform": "^1.1.1",
    "react-native-webpack-server": "^0.8.1",
    "react-transform-hmr": "^0.1.6",
    "webpack": "^1.12.6",
    "webpack-dev-server": "^1.12.1"
  }
}

I can see you merged a PR supposedly fixing that. I guess it is just a matter of time before you release? Downgrading webpack doesn't change anything. I even tried to clone the repo and add RNWS as a module to my project from the local repo, so with the latest changes, and still the same issue.

ded-ed commented 8 years ago

RN 0.14.2, RNWS 0.8.1

I move index.ios.js from "root/src" to the root of my project, therefore xcode building process will see index.ios.js. After it new errors come. There are troubles with relative paths using for import my modules (i think that root dir and alias not define by my webpack config).

Error

uncaught error Error: UnableToResolveError: Unable to resolve module common/btns/MenuMainBtn from /Users/Edward/Atlas/Application/project/src/common/NavBar.js: Invalid directory /Users/node_modules/common/btns/MenuMainBtn

This is strange, but script search my modules in Users dir instead of searching in project's root dir.

A part of webpack.config.js

resolve: {
        root: path.resolve(__dirname, 'src'),
        extensions: ['', '.js', '.jsx', '.es6'],
        alias: {llm: path.join(__dirname, "/lowlevel-modules")},
    }