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 find module './models/config' #1873

Closed
zackarychapple opened this issue Aug 29, 2016 · 39 comments
Closed

Cannot find module './models/config' #1873

zackarychapple opened this issue Aug 29, 2016 · 39 comments
Labels
needs: more info Reporter must clarify the issue

Comments

@zackarychapple
Copy link
Contributor

zackarychapple commented Aug 29, 2016

Running off the latest master I am getting the below error. @filipesilva @hansl
f9df8bb1730a5fe28e825db591a036157af34496 is the last commit that works for me.

Cannot find module './models/config'
Error: Cannot find module './models/config'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/zchapple/code/wfa_ng2/node_modules/angular-cli/addon/ng2/index.js:4:16)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)

Here is my current angular-cli config. From what I can tell matches the current one on master.

{
  "project": {
    "version": "1.0.0-beta.11-webpack.2",
    "name": "wfa-ng2"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": "assets",
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "wfa",
      "mobile": false,
      "styles":[
        "styles.css"
      ],
      "scripts": [
        "../public/d3/d3.min.js",
        "../public/lodash/lodash.min.js"
      ],
      "environments": {
        "source": "environments/environment.ts",
        "prod": "environments/environment.prod.ts",
        "dev": "environments/environment.dev.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "config/protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "config/karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": true,
    "lazyRoutePrefix": "+"
  }
}
@aBitNomadic
Copy link

aBitNomadic commented Aug 29, 2016

Just updated to the git repo and im getting the same error.
Found a workaround, npm install -g (repo) will cause this error, If you clone and npm link the you do not get this error

@ghost
Copy link

ghost commented Aug 30, 2016

I have a number of ng2 apps on my system. I took the node_modules folder for an app I updated yesterday and it worked!

@zackarychapple
Copy link
Contributor Author

Bumping global CLI allowed me to get past this as well.

@ghost
Copy link

ghost commented Aug 30, 2016

The change suggested by @zackarychapple worked for me.

@skdigital
Copy link

@zackarychapple Hi mate what do you mean by bumping? Not sure what you mean lol... I am stuck on the same problem.

@jasonswett
Copy link

For me the problem was that NVM wasn't using the right version of Node. I had installed angular-cli under Node 6.5.0 but then I opened a new terminal window that was using Node 4.0.0. Doing nvm use 6.5.0 fixed the problem.

@kylecordes
Copy link

I think this is related to some other problems that seem to go away, or not, based on Node versions. I made issue #1918 to look for a clarification of the versions. In the @jasonswett scenario, i suspect it would have worked for some Node 4.x.x, but not for 4.0.0. When some people say 4.x.x or 6.x.x they mean the most recent .x.x, and things usually work in those cases. When other people say those things they mean any .x.x, and I generally would not recommend anyone use any 4.0.0 or 6.0.0 for anything, you need to go up a few minor versions to pick up all the stuff that was broken in a .0 release and got fixed later.

@skdigital
Copy link

@kylecordes I am stuck still getting the same errors as posted above. I am using node 6.5.0 and have installed webpack version globally. I am running out of ideas...

@ghost
Copy link

ghost commented Aug 31, 2016

OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

MacbookPRO / El Capitan

$ node --version
v6.5.0

$ npm --version
3.10.3

$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: darwin x64

Repro steps. Was this an app that wasn't created using the CLI? What change did you

do on your code? etc.
Using the above configuration I executed the following steps

$ ng build my_project
$ cd my_project
$ ng build

The log given by the failure. Normally this include a stack trace and some

more information.

This issue seems to be related to issue #1887

It has been suggested that upgrading to node 6.5.0 might solve the problem. Unfortunately, as shown by the logs below, this is not the case:

$ node --version
v6.5.0

$ npm --version
3.10.3

$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: darwin x64

$ ng build
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
1019ms building modules                                                              
1ms sealing 
0ms optimizing 
1ms basic module optimization 
1ms module optimization 
0ms advanced module optimization 
2ms basic chunk optimization        
1ms chunk optimization 
0ms advanced chunk optimization 
0ms module and chunk tree optimization 
3ms module reviving 
0ms module order optimization 
0ms module id optimization 
1ms chunk reviving 
0ms chunk order optimization 
1ms chunk id optimization 
2ms hashing 
0ms module assets processing 
6ms chunk assets processing 
1ms additional chunk assets processing 
0ms recording 
1ms additional asset processing 
76ms chunk asset optimization
193ms asset optimization
4ms emitting 
Hash: 8633515b4611dd25238a
Version: webpack 2.1.0-beta.21
Time: 1329ms
            Asset       Size  Chunks             Chunk Names
   main.bundle.js    19.3 kB    0, 2  [emitted]  main
 styles.bundle.js      13 kB    1, 2  [emitted]  styles
        inline.js    5.53 kB       2  [emitted]  inline
         main.map    15.4 kB    0, 2  [emitted]  main
       styles.map    17.9 kB    1, 2  [emitted]  styles
       inline.map    5.59 kB       2  [emitted]  inline
       index.html  481 bytes          [emitted]  
assets/.npmignore    0 bytes          [emitted]  
chunk    {0} main.bundle.js, main.map (main) 13.8 kB {1} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.map (styles) 12.7 kB {2} [initial] [rendered]
chunk    {2} inline.js, inline.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve '@angular/platform-browser-dynamic' in '/Users/silveir/Projects/studies/ng2_router/src'
 @ ./src/main.ts 2:0-75
 @ multi main

.... many more errors of this nature

Mention any other details that might be useful.

Ive tried the steps above with many different typescript versions

@monojack
Copy link
Contributor

check your package.json file for
"e2e": { "protractor": { "config": "config/protractor.conf.js" } }, "test": { "karma": { "config": "config/karma.conf.js" } },

the config directory was removed and the files moved to root level.
change to "config": "./karma.conf.js" and "config": "./protractor.conf.js"

@ghost
Copy link

ghost commented Aug 31, 2016

I was able to solve this problem with the following configuration:

Upgrade imy tools

 node --version
v6.5.0
$ npm --version
3.10.3
$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: darwin x64

$ npm list -g
/usr/local/lib
├─┬ angular-cli@1.0.0-beta.11-webpack.8
│ ├── @angular-cli/ast-tools@1.0.0

...

├── typescript@2.0.0

....

Changed "typescript": "^2.0.0"to "typescript": "2.0.0"in mypackages.json`

Executed the folling commands on my project root

$ rm -rf node_modules dist tmp typings
$ npm install --save-dev angular-cli@webpack

@knicholes
Copy link

I'm seeing the same problem. I'm using docker, but my Dockerfile is simply

FROM node:6.5
RUN npm install -g angular-cli gulp

Then I'm running in my built container ng build
to see the following error:
Cannot find module './models/config' Error: Cannot find module './models/config' at Function.Module._resolveFilename (module.js:455:15) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at Object.<anonymous> (/tmp/node_modules/angular-cli/addon/ng2/index.js:4:16) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3)

@batchu
Copy link

batchu commented Aug 31, 2016

Same problem here

Error: Cannot find module './models/config'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object. (C:\dev\projects\client-phr-identity\node_modules\angular-cli\addon\ng2\index.js:4:16)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)

@eduardoturconi
Copy link

I tried everything above and I'm still getting the same error

@skdigital
Copy link

same lol

@arjenbrandenburgh
Copy link

+1

@cladera
Copy link
Contributor

cladera commented Sep 2, 2016

Same here :(

@ForbiddenUser
Copy link

ForbiddenUser commented Sep 2, 2016

I had the same issue, so I updated angular cli webpack like the tutorial provided in the readme https://github.com/angular/angular-cli/blob/master/WEBPACK_UPDATE.md .

Snippet of the readme:

Global package:

npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@webpack

Local project package:

# commit any changes you have to git first
rm -rf node_modules dist tmp typings
npm install --save-dev angular-cli@webpack

(I deleted the whole node_modules folder)

Project files:

You will need to run ng init to check for changes in all the auto-generated files created by ng new and allow you to update yours. You are offered four choices for each changed file: y (overwrite), n (don't overwrite), d (show diff between your file and the updated file) and h (help).

Carefully read the diffs for each code file, and either accept the changes or incorporate them manually after ng init finishes.

Maybe you need to edit the package.json file if angular isn't finding any names like 'Array' or so.
Change the line with "typescript": "^2.0.0" to "typescript": "2.0.0".

@chalin
Copy link

chalin commented Sep 4, 2016

FYI, I'm using v5 (5.12.0), and I was able to side-step the Cannot find module './models/config' issue by invoking ng build and ng serve via an npm script, instead of directly from the command line -- package.json excerpt:

{
  "name": "angular-io",
  ...
  "angular-cli": {},
  "scripts": {
    "build": "ng build", ...
    "serve": "ng serve", ...
  },
}

cc @ericjim

@Renader
Copy link

Renader commented Sep 6, 2016

@chalin might it just be that your global version is angular-cli@latest but your project version is angular-cli@webpack

@chalin
Copy link

chalin commented Sep 12, 2016

@Renader - I don't think I had the cli installed globally at the time, but maybe I did. Thanks.

@benlesh
Copy link
Contributor

benlesh commented Sep 12, 2016

FWIW: I hit this same issue last night.

  • Node 6.5
  • npm 3.10.3

fresh install.

npm uninstall angular-cli && npm i -g angular-cli@webpack

Tried uninstalling and reinstalling webpack. Tried uninstalling webpack, uninstalling angular-cli, then reinstalling angular-cli, then reinstalling webpack.

No combination works. cc @hansl

@jasonswett
Copy link

If you're experiencing the issue, be sure you're using the version of Node you think you're using. You can have 6.5.0 installed and still be using 4.0.0, for example. I always have to run nvm use when I enter a directory for the first time in order it to pick up my nvmrc which tells NVM to use Node 6.5.0.

@benlesh
Copy link
Contributor

benlesh commented Sep 12, 2016

@jasonswett no dice. Confirmed to be using Node 6.5.0. Same error

@keithmichelson
Copy link

I'm getting this too, strange it wasn't happening last night and I don't believe I've changed anything.

@arjenbrandenburgh
Copy link

arjenbrandenburgh commented Sep 13, 2016

I fixed this error. Turns out that angular-cli was installed globally in two locations (still don't know how I managed to do that). Once in the nodeJS directory and once in the users/AppData/Roaming/npm. What happened is that in the command-line, angular-cli was still pointing to the webpack.2 install instead of the webpack.8.

Once I figured this out and properly installed the webpack.8 and made sure my package.json included the webpack.8 version, the error was resolved.

So:
npm uninstall -g angular-cli
npm install -g angular-cli@1.0.0-beta.11-webpack.8

And put the angular-cli 1.0.0-beta.11-webpack.8 in your package.json

@yuri1969
Copy link

@cybey Yes! Uninstalling and reinstalling it again with precise version worked...

Used node 6.5.0.

@RaulGarafulic
Copy link

Weirdest thing:

I get the error when I command ng serve, but when I command npm start, it executes ng serve and it works perfectly.

@benlesh
Copy link
Contributor

benlesh commented Sep 16, 2016

In my case, I found a node_modules/ directory living in my user folder. Not sure how it got there, but deleting it resolved my issue.

@filipesilva filipesilva added the needs: more info Reporter must clarify the issue label Sep 22, 2016
@filipesilva
Copy link
Contributor

These issues seem related to some odd situations where several angular-cli global installs are present.

Does anyone still have does problem with beta.15?

If so, do these comments help? @Blesh's in #1873 (comment) or @cybey's #1873 (comment)

@stefanaerts
Copy link

if you run npm start it will work if you have ng serve defined as start in the package.json.

@stefanaerts
Copy link

@filipesilva beta.15 works.
So i had beta.15 installed global(npm-g),
but in the project i checked out from github i had in package.json version .8 .
When i run from terminal ng serve it didnt work, but when i run npm start it worked.
Now i changed the package.json to the beta.15 version and ng serve works.

@theunreal
Copy link

Got the same issue. Cannot use ng new to create a new project. It works if I install -g angular-cli@1.0.0-beta.11-webpack.8 but then I get errors when I'm trying to ng serve because it says I created my project using old version of the CLI...

@theunreal
Copy link

theunreal commented Oct 14, 2016

Hey @JanStureNielsen , I did

npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@latest`

then try to ng new and I get the same error. I couldn't run rm -rf node_modules dist tmp because I am on Windows. I did try to look for hidden folders but there was only one .git folder

@Faey2222
Copy link

Got the exact same problems... Fresh Windows install.

Node: v6.8.0
NPM: 3.10.8
Angular-CLI: 1.0.0-beta.17

No matter what I try everything fails and as result I receive the same error over and over again.

@filipesilva
Copy link
Contributor

@theunreal @Celaniry if you still have problems please open a new issue with detailed description. I don't think you can have the same issue as the original comments because it was related with running off latest master.

@SimonBiggs
Copy link

I was getting this error with the current latest npm angular-cli package. However it turns out I had a left over npm / nodejs within my ubuntu distribtuion. I fixed the issue by completely removing node and npm from every location. I then reinstalled node via nvm.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests