question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't resolve local js dependencies

See original GitHub issue

Description

After upgrading to latest version (2.6.1) or even using the version on master I get the following error while brunch builds the javascript files on my project:

04 Apr 16:48:53 - error: Resolving deps of web/static/js/app.js failed. Could not load module 'web/static/js/store' from '/Users/ricardogarciavega/Documents/projects/codeloveandboards/myapp/web/static/js'. Possible solution: add 'web' to package.json and `npm install`.

This only happens while importing local modules and not with the ones installed with npm.

Environment

  1. Brunch: 2.6.1
  2. Node: v5.10.0
  3. NPM: 3.8.3
  4. Operating system: OSX El Capitan

package.json contents

{
  "repository": {},
  "dependencies": {
    "babel-brunch": "~6.0.0",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.3.13",
    "babel-preset-stage-0": "^6.3.13",
    "babel-preset-stage-2": "^6.3.13",
    "brunch": "github:brunch/brunch",
    "classnames": "^2.2.3",
    "clean-css-brunch": "^2.0.0",
    "css-brunch": "^2.6.1",
    "history": "^2.0.1",
    "invariant": "^2.2.1",
    "javascript-brunch": "^2.0.0",
    "normalize.styl": "^3.0.3",
    "phoenix": "file:deps/phoenix",
    "phoenix_html": "file:deps/phoenix_html",
    "react": "^0.14.8",
    "react-addons-css-transition-group": "^0.14.8",
    "react-dom": "^0.14.8",
    "react-redux": "^4.4.1",
    "react-router": "^2.0.1",
    "react-router-redux": "^4.0.0",
    "redux": "^3.1.2",
    "redux-logger": "^2.6.1",
    "redux-thunk": "^2.0.1",
    "stylus-brunch": "^2.6.0",
    "uglify-js-brunch": "^2.0.1"
  }
}

brunch config contents

exports.config = {
  files: {
    javascripts: {
      joinTo: 'js/app.js',
    },
    stylesheets: {
      joinTo: 'css/app.css',
    },
    templates: {
      joinTo: 'js/app.js',
    },
  },

  conventions: {
    assets: /^(web\/static\/assets)/,
  },

  paths: {
    watched: [
      'web/static',
      'test/static',
    ],

    public: 'priv/static',
  },

  plugins: {
    babel: {
      presets: ['es2015', 'react', 'stage-2', 'stage-0'],

      ignore: [/web\/static\/vendor/],
    },

    stylus: {
      plugins: [
      ],

      linenos: true,
    },
  },

  modules: {
    autoRequire: {
      'js/app.js': ['web/static/js/app'],
    },
  },

  npm: {
    enabled: true,

    whitelist: [
      'classnames',
      'history',
      'invariant',
      'phoenix',
      'phoenix_html',
      'react',
      'react-addons-css-transition-group',
      'react-dom',
      'react-redux',
      'react-router',
      'react-router-redux',
      'redux',
      'redux-logger',
      'redux-thunk',
    ],
  },
};

Other useful files, when present (bower.json etc.)

Sample app.js:

import React                    from 'react';
import ReactDOM                 from 'react-dom';
import { browserHistory }       from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import configureStore           from './store';
import Root                     from './containers/root';

const store  = configureStore(browserHistory);
const history = syncHistoryWithStore(browserHistory, store);

const target = document.getElementById('main_container');
const node = <Root routerHistory={history} store={store}/>;

ReactDOM.render(node, target);

Error:

04 Apr 16:48:53 - error: Resolving deps of web/static/js/app.js failed. Could not load module 'web/static/js/store' from '/Users/ricardogarciavega/Documents/projects/codeloveandboards/myapp/web/static/js'. Possible solution: add 'web' to package.json and `npm install`.
04 Apr 16:48:53 - error: Resolving deps of web/static/js/containers/root.js failed. Could not load module 'web/static/js/routes' from '/Users/ricardogarciavega/Documents/projects/codeloveandboards/myapp/web/static/js/containers'. Possible solution: add 'web' to package.json and `npm install`.
04 Apr 16:48:53 - error: Resolving deps of web/static/js/routes/index.js failed. Could not load module 'web/static/js/views/home' from '/Users/ricardogarciavega/Documents/projects/codeloveandboards/myapp/web/static/js/routes'. Possible solution: add 'web' to package.json and `npm install`.
04 Apr 16:48:53 - error: Resolving deps of web/static/js/store/index.js failed. Could not load module 'web/static/js/reducers' from '/Users/ricardogarciavega/Documents/projects/codeloveandboards/myapp/web/static/js/store'. Possible solution: add 'web' to package.json and `npm install`.

If I downgrade to version 2.6.0 it works as expected and the js gets compiled without any errors. Thanks in advance 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
xdavecommented, Apr 5, 2016
0reactions
xdavecommented, Apr 5, 2016

@goshakkk Yes, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't npm install local dependency - Stack Overflow
Method 1: Using npm-link. Go to C:\Users\user\projects\react-financial-charts in terminal: npm link.
Read more >
Unable to resolve locally installed module #29977 - GitHub
Description. App breaks with error Unable to resolve module {moduleName} from {place} : {moduleName} could not be found within the project ...
Read more >
How to resolve "Cannot find module" error in Node - Sabe.io
The Cannot find module error is a common error that usually happens when dependencies are not installed. Once you install your dependencies and ......
Read more >
package.json - npm Docs
URLs as Dependencies. You may specify a tarball URL in place of a version range. This tarball will be downloaded and installed locally...
Read more >
Resolve | webpack
When enabled, webpack would prefer to resolve module requests as relative requests instead of using modules from node_modules directories. webpack.config.js
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found