Nuxt.js: src folder?

Created on 8 Dec 2016  Â·  10Comments  Â·  Source: nuxt/nuxt.js

Is there a simple way to make nuxt look for everything in a ./src folder, instead of the root?

This feature request is available on Nuxt.js community (#c36)

Most helpful comment

@Atinux I propose considering making ./src the default folder, to bring it to parity with how vue-cli generates projects - makes for a more consistent experience imo. just a thought!

All 10 comments

Ok, so looking through the code there is a rootDIr option. After setting that to ./src, I get the following error:

â—‹ nuxt
  nuxt:build App root: src +0ms
  nuxt:build Generating .nuxt/ files... +2ms
  nuxt:build Generating routes... +6ms
  nuxt:build Generating files... +7ms
  nuxt:build Adding webpack middlewares... +13ms
Ready on http://localhost:3000
webpack built 6040be73cf7bdbc8b0ad in 123ms
Hash: 6040be73cf7bdbc8b0ad
Version: webpack 2.1.0-beta.27
Time: 123ms
               Asset       Size  Chunks       Chunk Names
      nuxt.bundle.js  399 bytes       0       app
    vendor.bundle.js    30.7 kB       1       vendor
  nuxt.bundle.js.map   91 bytes       0       app
vendor.bundle.js.map    32.2 kB       1       vendor

ERROR in multi vendor
Module not found: Error: Can't resolve 'vue' in '/Users/cj/Sync/apps/acd/nuxt'
 @ multi vendor

ERROR in multi vendor
Module not found: Error: Can't resolve 'vue-router' in '/Users/cj/Sync/apps/acd/nuxt'
 @ multi vendor

ERROR in multi vendor
Module not found: Error: Can't resolve 'vue-meta' in '/Users/cj/Sync/apps/acd/nuxt'
 @ multi vendor

ERROR in multi vendor
Module not found: Error: Can't resolve 'es6-promise' in '/Users/cj/Sync/apps/acd/nuxt'
 @ multi vendor

ERROR in multi vendor
Module not found: Error: Can't resolve 'es6-object-assign' in '/Users/cj/Sync/apps/acd/nuxt'
 @ multi vendor

ERROR in multi app
Module not found: Error: Can't resolve 'babel-loader' in '/Users/cj/Sync/apps/acd/nuxt'
 @ multi app

ERROR in multi app
Module not found: Error: Can't resolve 'webpack-hot-middleware/client?reload=true' in '/Users/cj/Sync/apps/acd/nuxt'
 @ multi app
Entry module not found: Error: Can't resolve 'babel-loader' in '/Users/cj/Sync/apps/acd/nuxt'
resolve 'babel-loader' in '/Users/cj/Sync/apps/acd/nuxt'
  Parsed request is a module
  using description file: /Users/cj/Sync/apps/acd/nuxt/package.json (relative path: .)
  after using description file: /Users/cj/Sync/apps/acd/nuxt/package.json (relative path: .)
    resolve as module
      /Users/cj/Sync/apps/acd/nuxt/src/node_modules doesn't exist or is not a directory
      /Users/cj/Sync/apps/src/node_modules doesn't exist or is not a directory
      /Users/cj/Sync/apps/acd/src/node_modules doesn't exist or is not a directory
      /Users/cj/Sync/src/node_modules doesn't exist or is not a directory
      /Users/cj/src/node_modules doesn't exist or is not a directory
      /Users/src/node_modules doesn't exist or is not a directory
      /src/node_modules doesn't exist or is not a directory
      looking for modules in /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/node_modules
        using description file: /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/package.json (relative path: ./node_modules)
        after using description file: /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/package.json (relative path: ./node_modules)
          using description file: /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/package.json (relative path: ./node_modules/babel-loader)
            as directory
              /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/node_modules/babel-loader doesn't exist
            no extension
              /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/node_modules/babel-loader doesn't exist
            .js
              /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/node_modules/babel-loader.js doesn't exist
            .json
              /Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/node_modules/babel-loader.json doesn't exist

/Users/cj/Sync/apps/acd/nuxt/node_modules/memory-fs/lib/MemoryFileSystem.js:114
                        throw new MemoryFileSystemError(errors.code.ENOENT, _path);
                        ^
Error: no such file or directory
    at MemoryFileSystem.readFileSync (/Users/cj/Sync/apps/acd/nuxt/node_modules/memory-fs/lib/MemoryFileSystem.js:114:10)
    at Watching.webpackServerWatcher.serverCompiler.watch [as handler] (/Users/cj/Sync/apps/acd/nuxt/node_modules/nuxt/lib/build/index.js:268:35)
    at Watching._done (/Users/cj/Sync/apps/acd/nuxt/node_modules/webpack/lib/Compiler.js:96:7)
    at /Users/cj/Sync/apps/acd/nuxt/node_modules/webpack/lib/Compiler.js:76:18
    at Compiler.emitRecords (/Users/cj/Sync/apps/acd/nuxt/node_modules/webpack/lib/Compiler.js:350:37)
    at /Users/cj/Sync/apps/acd/nuxt/node_modules/webpack/lib/Compiler.js:59:19
    at /Users/cj/Sync/apps/acd/nuxt/node_modules/webpack/lib/Compiler.js:343:11
    at Compiler.applyPluginsAsyncSeries (/Users/cj/Sync/apps/acd/nuxt/node_modules/tapable/lib/Tapable.js:95:46)
    at Compiler.afterEmit (/Users/cj/Sync/apps/acd/nuxt/node_modules/webpack/lib/Compiler.js:340:8)
    at Compiler.<anonymous> (/Users/cj/Sync/apps/acd/nuxt/node_modules/webpack/lib/Compiler.js:335:14)

I'm trying to end up with this structure:


looks like there needs to be a srcDir option. going to fork and add one.

Hi @cj, why do you want to have this structure?

You need to have the node_modules/ and the nuxt.config.js in the src/ folder to make it work.

I´m looking for same option, I would like to move all file to a app folder to separate my server/api files, a rootDir option would be great!

app
|--components
|--pages
|--static
server
|--main.js
|--etc..

@danieloprado once the pull request is excepted you'll be able to do that. #44

I'm working on it to merge it pretty soon :)

You can now use the v0.8.4 🎊

@Atinux I propose considering making ./src the default folder, to bring it to parity with how vue-cli generates projects - makes for a more consistent experience imo. just a thought!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikekidder picture mikekidder  Â·  3Comments

danieloprado picture danieloprado  Â·  3Comments

vadimsg picture vadimsg  Â·  3Comments

nassimbenkirane picture nassimbenkirane  Â·  3Comments

pehbehbeh picture pehbehbeh  Â·  3Comments