gpt4 book ai didi

angularjs - 如何正确地将node_modules移动到不同的位置

转载 作者:太空宇宙 更新时间:2023-11-03 21:57:14 25 4
gpt4 key购买 nike

我正在尝试将我的node_modules移动到不同的位置,我所做的就是删除node_modules并将package.json移动到我想要安装它的位置,然后我运行npm install它在我想要的地方安装了node_modules,但现在,如果我运行npm start,服务器就会启动,并且会出现很多错误:

(index):5 GET http://localhost:3000/node_modules/bootstrap/dist/css/bootstrap.min.css 
(index):9 GET http://localhost:3000/node_modules/es6-shim/es6-shim.min.js
(index):10 GET http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js
(index):12 GET http://localhost:3000/node_modules/angular2/bundles/angular2-polyfills.js
(index):13 GET http://localhost:3000/node_modules/systemjs/dist/system.src.js
(index):14 GET http://localhost:3000/node_modules/rxjs/bundles/Rx.js
(index):15 GET http://localhost:3000/node_modules/angular2/bundles/angular2.dev.js
(index):16 GET http://localhost:3000/node_modules/angular2/bundles/http.dev.js
(index):21 Uncaught ReferenceError: System is not defined(anonymous function) @ (index):21

我更新了index.html 文件以使用根node_modules 中的文件而不是当前目录的node_modules。

我还应该做什么才能让它发挥作用?

请注意,index.html 与 node_modules 位于不同的目录中

最佳答案

解决办法如下:

  1. package.json 文件所在的同一目录中创建 bs-config.json 文件
  2. 将以下 json 放入 bs-config.json 文件中:

    { “服务器”: { "baseDir": "path/to/your/base/dir/where/you/have/the/index.html/of/your/app", “路线”:{ “/node_modules”:“/路径/到/Node/模块/相对/到/这个/文件” } } }

  3. 编辑您的package.json文件"lite": "lite-server --c bs-config.json"

  4. 运行npm start,它会像魔术一样工作:D

关于angularjs - 如何正确地将node_modules移动到不同的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37502044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com