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": "+"
}
}
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
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!
Bumping global CLI allowed me to get past this as well.
The change suggested by @zackarychapple worked for me.
@zackarychapple Hi mate what do you mean by bumping? Not sure what you mean lol... I am stuck on the same problem.
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.
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.
@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...
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
do on your code? etc.
Using the above configuration I executed the following steps
$ ng build my_project
$ cd my_project
$ ng build
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
Ive tried the steps above with many different typescript versions
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"
I was able to solve this problem with the following configuration:
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
├─┬ [email protected]
│ ├── @angular-cli/[email protected]
...
├── [email protected]
....
to "typescript": "2.0.0"in mypackages.json`$ rm -rf node_modules dist tmp typings
$ npm install --save-dev angular-cli@webpack
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)
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\projectsclient-phr-identitynode_modulesangular-cli\addonng2\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)
I tried everything above and I'm still getting the same error
same lol
+1
Same here :(
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".
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
@chalin might it just be that your global version is angular-cli@latest but your project version is angular-cli@webpack
@Renader - I don't think I had the cli installed globally at the time, but maybe I did. Thanks.
FWIW: I hit this same issue last night.
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
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.
@jasonswett no dice. Confirmed to be using Node 6.5.0. Same error
I'm getting this too, strange it wasn't happening last night and I don't believe I've changed anything.
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 [email protected]
And put the angular-cli 1.0.0-beta.11-webpack.8 in your package.json
@cybey Yes! Uninstalling and reinstalling it again with precise version worked...
Used node 6.5.0.
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.
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.
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 https://github.com/angular/angular-cli/issues/1873#issuecomment-246709480 or @cybey's https://github.com/angular/angular-cli/issues/1873#issuecomment-247689886
if you run npm start it will work if you have ng serve defined as start in the package.json.
@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.
Got the same issue. Cannot use ng new to create a new project. It works if I install -g [email protected] 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...
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
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.
@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.
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.
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._
Most helpful comment
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 [email protected]
And put the angular-cli 1.0.0-beta.11-webpack.8 in your package.json