I took 10 hours of research from me to find this:
npm start
A long story to compare your research approach:
After several unsuccessful attempts, I reinstalled node and npm, and now I have:
c:\> ng -v @angular/cli: 1.3.0 node: 6.9.0 os: win32 ia32
Everything works great for new projects.
ng new my-new-project
But I have a compromised project that shows
Unable to find "@angular/cli" in devDependencies. Please take the following steps to avoid issues: "npm install --save-dev @angular/cli@latest" The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli' Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli' at Object.<anonymous> (C:\Users\profimedica\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\index.js:14:11)
Since I already have @ angular / cli installed, I just had to add it to the package.json file , using as an example the same file from a newly created project that works fine
{ "dependencies": { "body-parser": "^1.17.1", "express": "^4.15.2", "http": "0.0.0" }, "devDependencies": { "@angular/cli": "1.3.0", "@angular/compiler-cli": "^4.2.4" } }
The second error is selected here because the @ angular / compiler-cli module is not installed as a local module:
// Check that Angular is available. try { version = require('@angular/compiler-cli').VERSION; } catch (e) { throw new Error('The "@angular/compiler-cli" package was not properly installed. Error: ' + e); }
I checked the node_modules folder and I noticed that the folders are. \ node_modules \ @angular \ compiler-cli,. \ node_modules \ @angular \ compiler and. \ node_modules \ @angular \ core, where missing.
I installed as needed:
npm install @angular/compiler-cli npm install @angular/compiler npm install @angular/core
I added the log to the file and I see the detected version after installation:. \ Node_modules \ @ngtools \ webpack \ src \ index.js
console.log(require('@angular/compiler-cli').VERSION); Version { full: '4.3.5' }
Now I get a new error:
Cannot read property 'config' of null TypeError: Cannot read property 'config' of null at Class.run (C:\PRO\htdocs\my\api\gen\projects\generated\testknowledge\node_modules\@angular\cli\tasks\serve.js:23:63)
To investigate this new issue, I added a log line to. \ node_modules \ @angular \ cli \ models \ config \ config.js
class CliConfig { constructor(_configPath, schema, configJson, fallbacks = []) { this._configPath = _configPath; console.log(_configPath); this._config = new (json_schema_1.SchemaClassFactory(schema))(configJson, ...fallbacks); }
And I got an unexpected value:
C:\Users\profimedica\.angular-cli.json
Obviously, this file is not in my home directory, and not in the root of the project:
.\angular-cli.json
After 3 hours of research and trying to create the missing files, I had to rethink the approach.
I removed the local @ angular module and reinstalled it globally:
npm install --save-dev @angular/cli@latest npm install --save-dev @angular/compiler-cli@latest npm install --save-dev @angular/compiler@latest npm install --save-dev @angular/core@latest
I found that my project has a user architecture and I had to run npm start