美好的一天,伙计们!\n我在网上寻找解决方案,但找不到,所以我向你寻求帮助。请耐心听我完整描述情况。
\n我是一名初学者,在开发引导 Web 项目时遇到了 Parcel 问题。\nFirst, it throws an error for using index.js which doesn\'t make any sense. As per the bootstrap, doc. folder structure suppose to be
project-name/\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 build/\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 node_modules/\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 bootstrap/\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 popper.js/\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 scss/\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 custom.scss\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 src/\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.html\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.js\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 package.json\nRun Code Online (Sandbox Code Playgroud)\n我正在严格遵循引导文档。链接: https: //getbootstrap.com/docs/5.0/getting-started/parcel/
\n项目使用的包:
\n包裹捆绑器,
\n波普尔和
\n引导程序
\n使用简单的 HTML 重新创建问题
\n索引.html
\n<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n …Run Code Online (Sandbox Code Playgroud) 我需要获取我的Angular 2应用程序的完整基本URL(例如http:// localhost:5000或https://productionserver.com),以便我可以在应用程序的上下文中将其传递给第三方服务.应用程序的位置取决于它是开发,各种登台/测试环境还是生产,我想动态检测它,所以我不需要维护硬编码列表.
一个类似的问题已经提出,在过去,但答案(即使用window.location.hostname或window.location.origin属性的某些版本),只有当angular2应用程序正在被浏览器呈现工作.
我希望我的应用程序可以与Angular Universal一起使用,这意味着它需要在服务器端呈现,而无法访问像window.location这样的DOM对象.
任何想法如何实现这一目标?供参考,使用asp.net核心作为后端(使用默认的dotnet新角度模板).
9 个月前,我在 Webpack One 上苦苦挣扎:
更新 30.04.20
我必须更新这一点,因为现在一切都不同了,正如你所知,在 Web 编程世界中,一切都发展得非常快,包括 Parcel、Rollup。和 webpack 现在您可以尝试许多不同的模块捆绑器。
现在我将向任何 JS Webpack 推荐这个入门包。我非常感谢Brian Staruk的帮助和不断更新,这对我们所有的项目以及我工作的公司的项目都有帮助。
https://github.com/bstaruk/starbase
=========================================
更新 24.07.17 || v1
我们终于成功了,这是一个简单的语法问题:
//-- webpack.config.js
'use strict';
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractStyles = new ExtractTextPlugin('styles.bundle.css');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
let start = {
context: path.resolve(__dirname, 'src'),
entry: {
scripts: './_scripts.js',
},
module: {
rules: [
{
test: /\.css$/,
use: …Run Code Online (Sandbox Code Playgroud)当我将 Jest 与 Antd、React 和 Parcel 结合使用时,出现以下错误。Jest 抱怨 Antd css 文件。Jest 是否应该默认包含 node_modules ?如果不是,是否可以排除它?
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not > plain JavaScript.
{ProjectPath}/node_modules/antd/lib/style/index.css:5
.ant-modal,
^
SyntaxError: Unexpected token '.'
8 |
9 |
> 10 | export default () => {
Run Code Online (Sandbox Code Playgroud)
笑话配置.js
{
"jest": {
"setupFilesAfterEnv": [
"<rootDir>src/setupTests.js"
],
"transform": {
"^.+\\.js$": "babel-jest",
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
}
}
}
Run Code Online (Sandbox Code Playgroud)
.babelrc
{
"presets": [ …Run Code Online (Sandbox Code Playgroud) 我正在制作一个聊天机器人。当用户给出新输入或通过 API 发送数据时,我想滚动到聊天框的底部。
它不滚动,滚动只是停留在同一位置,但数据正在添加到聊天框中
我已经尝试过其他聊天机器人的代码,但它也不起作用
var outputArea = $('#chat-output');
$('#user-input-form').on('submit', function (e) {
e.preventDefault();
var message = $('#user-input').val();
outputArea.append(`
<div class='bot-message'>
<div class='message'>
${message}
</div>
</div>
`);
const req = https.request(options, (res) => {
res.setEncoding('utf8');
res.on('data', (d) => {
const myobj = JSON.parse(d);
if ('narrative' in myobj.conversationalResponse.responses[0]) {
const temp = myobj.conversationalResponse.responses[0].narrative.text;
outputArea.append(`
<div class='user-message'>
<div class='message'>
${temp}
</div>
</div>
`);
} else if ('imageUrl' in myobj.conversationalResponse.responses[0]) {
const img = myobj.conversationalResponse.responses[0].imageUrl;
if ('narrative' in myobj.conversationalResponse.responses[1]) {
const text_r = …Run Code Online (Sandbox Code Playgroud)我正在使用带有 typescript 的 Parcel,开箱即用,一切正常,现在当我尝试包含 svg 时,它不起作用,
这是因为我需要更改打字稿
declare module "*.svg"
Run Code Online (Sandbox Code Playgroud)
这使我现在可以编译我的打字稿。
现在另一件事不起作用是现在我想导入我的 SVG 组件并像 create-react-app 2 一样使用它
从“./icon.svg”导入图标
function DisplayIcon(){
return <Icon/>
}
Run Code Online (Sandbox Code Playgroud)
所以这看起来很简单 https://www.npmjs.com/package/@svgr/parcel-plugin-svgr yarn install ,我得到 Can'tsolve
<Typescript file>:<Line>:<Column>: Cannot resolve dependency './icon.svg' at '<Icon Location>'
Run Code Online (Sandbox Code Playgroud)
所以我想也许是插件的问题,我尝试使用
https://www.npmjs.com/package/parcel-plugin-inlinesvg
我也遇到同样的问题。
我缺少什么?
我看到有些人有 .babelrc 文件,但插件应该至少能解决文档所说的问题。
在 Parcel 中使用插件再简单不过了。您所需要做的就是安装并将它们保存在 package.json 中。插件应使用前缀parcel-plugin- 或@your-scope/parcel-plugin- 命名,例如parcel-plugin-foo 或@your-scope/parcel-plugin-foo。package.json 中列出的具有这些前缀的任何依赖项都将在初始化期间自动加载。
插件似乎启动了,但没有任何作用。
如果没有插件,我会在公共路径中获取该文件,并在 JavaScript 运行时中获取一个字符串。
我错过了什么以及我做错了什么?
我一直在尝试安装这个包裹模块,但多次失败,因此我无法显示图像。我对使用 JS 和 Parcel 都很陌生,而且英语不是我的母语,所以请耐心等待。
出现的错误是
无法安装 @parcel/transformer-image:npm 无法安装模块:意外的令牌 > 在 JSON 中的位置 1
我尝试了多种解决方案:
起初,构建不起作用,但是当我停用并再次激活包裹时,它起作用了,但没有加载图像。此时,错误不再出现,但图像仍然无法加载(我检查了元素并发现应加载图像的链接是正确的)。
安装 nodist 后,甚至在卸载它后,我在安装包裹时遇到了问题,但无论如何我还是成功了。
我正在尝试用包裹建立一个项目。我已按照作业中的所有说明进行操作,但每当我尝试运行时,此错误都会出现在我的终端上:
\nparcel src/index.html\nRun Code Online (Sandbox Code Playgroud)\n这是错误消息:
\n构建失败。
\n\n\n@parcel/core:目标“main”中出现意外的输出文件类型 .html
\nC:\\Users\\johan\\myflix-client\\package.json:4:11\n3 | “版本”:“1.0.0”,
\n\n\n4 | "main": "src/index.html",\n| ^^^^^^^^^^^^^^^^^ 文件扩展名必须是 .js、.mjs 或 .cjs\n5 | “脚本”:{\n6 | “测试”:“回显“错误:未指定测试”&& 退出 1”
\n\xe2\x84\xb9 “main”字段用于库。如果您打算输出\n.html 文件,请删除“主”字段或选择\n不同的目标名称。
\n
我什至尝试完全删除“main”,尽管我被告知我需要它,但它只会引发更多错误。
\n请对此提供任何帮助,我们将不胜感激!
\n我最近将 Windows 从 Windows 10 更新到了 11。
\n** 更新 ** 我再次重新安装了 Windows 10,但收到了同样的错误
\n当我运行yarn start或npm start时,我收到以下错误
\n\xce\xbb yarn start\nyarn run v1.22.15\n$ parcel index.html\nError: The specified module could not be found.\n\\\\?\\C:\\Users\\Ammar Home\\Desktop\\testing\\node_modules\\@parcel\\fs-search\\fs-search.win32-x64-msvc.node\n at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)\n at Module.load (internal/modules/cjs/loader.js:950:32)\n at Function.Module._load (internal/modules/cjs/loader.js:790:12)\n at Module.require (internal/modules/cjs/loader.js:974:19)\n at require (C:\\Users\\Ammar Home\\Desktop\\testing\\node_modules\\v8-compile-cache\\v8-compile-cache.js:159:20)\n at Object.<anonymous> (C:\\Users\\Ammar Home\\Desktop\\testing\\node_modules\\@parcel\\fs-search\\index.js:19:20)\n at Module._compile (C:\\Users\\Ammar Home\\Desktop\\testing\\node_modules\\v8-compile-cache\\v8-compile-cache.js:192:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)\n at Module.load (internal/modules/cjs/loader.js:950:32)\n at Function.Module._load (internal/modules/cjs/loader.js:790:12) {\n code: 'ERR_DLOPEN_FAILED'\n}\nerror Command failed with exit code 1.\ninfo Visit https://yarnpkg.com/en/docs/cli/run for documentation …Run Code Online (Sandbox Code Playgroud) 我的 package.json 文件
{
"name": "aiky",
"version": "1.0.0",
"description": "Recipe application",
"default": "index.html",
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html --dist-dir ./dist"
},
"author": "Akash Kesharwani",
"license": "ISC",
"devDependencies": {
"@parcel/resolver-glob": "^2.0.0-rc.0",
"@parcel/transformer-image": "^2.0.0-rc.0",
"@parcel/transformer-sass": "^2.0.0-rc.0",
"parcel": "^2.0.0-rc.0",
"sass": "^1.26.10"
},
"dependencies": {
"core-js": "^3.6.5",
"fractional": "^1.0.0",
"regenerator-runtime": "^0.13.7"
},
"main": "index.js"
}
Run Code Online (Sandbox Code Playgroud)
我无法通过互联网找到解决方案。在此之前,我收到此错误
@parcel/core: Failed to resolve 'src/img/test-1.jpg' from './index.html'
@parcel/resolver-default: Cannot load file './src/img/test-1.jpg' in './'.
Run Code Online (Sandbox Code Playgroud)
因此,我安装了 @parcel/resolver-glob 并在根目录中添加了.parcelrc和此文本
{
"extends": "@parcel/config-default",
"resolvers": ["@parcel/resolver-glob"] …Run Code Online (Sandbox Code Playgroud) parceljs ×9
javascript ×5
html ×2
node.js ×2
reactjs ×2
angular ×1
antd ×1
bootstrap-5 ×1
browser ×1
css ×1
jestjs ×1
module ×1
npm ×1
package.json ×1
popperjs ×1
rollup ×1
svg ×1
webpack ×1
webpack-3 ×1
windows-11 ×1