[英]Copying Angular project directory does not work
Using Angular quickstart script is as follows:使用Angular快速启动脚本如下:
git clone https://github.com/angular/quickstart.git quickstart
cd quickstart
npm install
npm start
When I do this, everything works fine.当我这样做时,一切正常。 However, if I copy this directory to create a new Angular project:
但是,如果我复制这个目录来创建一个新的 Angular 项目:
cp -r quickstart angular-project
cd angular-project
npm install
npm start
an error occurs:出现错误:
module.js:472
throw err;
^
Error: Cannot find module '../lib/tsc.js'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/username/src/angular/quickstart-test1/node_modules/.bin/tsc:2:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
even though tsc.js
exists under lib/
in new directory.即使
tsc.js
存在于新目录中的lib/
下。
Why does this error occur?为什么会出现这个错误?
This is how you'd get around this issue. 这是解决该问题的方法。
if you named your copy of the quickstart project angular-project; 如果您将快速启动项目的副本命名为angular-project;
Most likely the problem is that the file .angular-cli.json was not copied by "cp" command to your new directory. 最有可能的问题是文件.angular-cli.json没有通过“ cp”命令复制到您的新目录中。 Add it manually and change the project name inside of it.
手动添加它并在其中更改项目名称。
you can't copy it with cp -r
. 您不能使用
cp -r
复制它。 You need to run npm install
again to recreate the packages used by the Node.js
. 您需要再次运行
npm install
来重新创建Node.js
使用的软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.