所以,我以前多次使用 Parcel,我从来没有遇到过问题。这一次它抛出了一些关于 SemVer 版本控制的愚蠢错误,我真的很想找到解决这个问题的解决方案。
我开始了新项目:安装了 npm w/ npm init(没有其他选项),然后安装了 Parcel npm install --save-dev parcel-bundler,然后创建了我的文件夹结构:
--node_modules
--index.html
--index.js
这是我的 package.json:
{
"name": "playground",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "parcel index.html"
},
"author": "",
"license": "ISC",
"devDependencies": {
"parcel-bundler": "^1.12.4"
}
}
Run Code Online (Sandbox Code Playgroud)
我已经配置了默认的 npm 脚本来运行包:"dev": "parcel index.html"并运行它。一切正常,但是当我通过<script src="/index.js"></script>它在 index.html 中连接我的 index.js 时,它会抛出很大的错误,说:
Run Code Online (Sandbox Code Playgroud)D:\workingSpace\playground\index.js: Invalid Version: undefined at new SemVer (D:\workingSpace\playground\node_modules\@babel\preset-env\node_modules\semver\semver.js:314:11) at compare (D:\workingSpace\playground\node_modules\@babel\preset-env\node_modules\semver\semver.js:647:10) at lt (D:\workingSpace\playground\node_modules\@babel\preset-env\node_modules\semver\semver.js:688:10) at D:\workingSpace\playground\node_modules\@babel\preset-env\lib\index.js:276:22 at Object.default (D:\workingSpace\playground\node_modules\@babel\helper-plugin-utils\lib\index.js:22:12) at …
目前在我们的Sass文件中,我们有类似以下内容:
@import "../../node_modules/some-module/sass/app";
Run Code Online (Sandbox Code Playgroud)
这很糟糕,因为我们实际上并不确定路径:它可能是../node_modules,它可能是../../../../../node_modules,因为npm如何安装东西.
在Sass中我们可以搜索到找到node_modules吗?甚至是通过npm包括Sass的正确方法?
阅读完.dockerignore文档后,我想知道是否有办法测试它?
**/node_modules/
Run Code Online (Sandbox Code Playgroud)
如何检查我的dockerfile忽略正确的文件和目录?
我在查看node.js模块文档,并注意到每个模块都有一个属性 - module.parent.我试图使用它,但是被模块缓存烧毁了 - module.parent只有在首先需要()它的模块看来,无论当前的上下文如何.
那么它的用途是什么?有没有其他方法可以获得对当前 require()模块的引用?现在我将模块包装在一个函数中,因此它被调用为:
require("mylibrary")(module)
Run Code Online (Sandbox Code Playgroud)
但这似乎不是最佳的.
我有在node_modulesDocker容器内安装并与主机同步的问题.我的Docker的版本是18.03.1-ce, build 9ee9f40和Docker Compose的版本一样1.21.2, build a133471.
我docker-compose.yml看起来像:
# Frontend Container.
frontend:
build: ./app/frontend
volumes:
- ./app/frontend:/usr/src/app
- frontend-node-modules:/usr/src/app/node_modules
ports:
- 3000:3000
environment:
NODE_ENV: ${ENV}
command: npm start
# Define all the external volumes.
volumes:
frontend-node-modules: ~
Run Code Online (Sandbox Code Playgroud)
我的Dockerfile:
# Set the base image.
FROM node:10
# Create and define the working directory.
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
# Install the application's dependencies.
COPY package.json ./
COPY package-lock.json ./
RUN npm install …Run Code Online (Sandbox Code Playgroud) 你好我有以下错误,我在vuejs中有一个应用程序,它运行良好,错误突然出现,重新安装了所有东西,清理缓存,我找不到解决方法,希望你的帮助
错误:规则中只能有一个资源源(提供的资源和测试+包含+排除)
"exclude": [
null
],
"use": [
{
"loader": "/Users/juanpablo/front-treatments/node_modules/cache-loader/dist/cjs.js",
"options": {
"cacheDirectory": "/Users/juanpablo/front-treatments/node_modules/.cache/babel-loader",
"cacheIdentifier": "81fef5a6"
},
"ident": "clonedRuleSet-38[0].rules[0].use[0]"
},
{
"loader": "/Users/juanpablo/front-treatments/node_modules/babel-loader/lib/index.js",
"options": "undefined",
"ident": "undefined"
}
]
} ````
A complete log of this run can be found in:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/Users/juanpablo/.nvm/versions/node/v12.19.0/bin/node',
1 verbose cli '/Users/juanpablo/.nvm/versions/node/v12.19.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'serve'
1 verbose cli ]
2 info using npm@6.14.8
3 …Run Code Online (Sandbox Code Playgroud) var t = "\some\route\here"
我需要"\ some\route".
谢谢.
我只想将socket.io安装到我的项目,该项目位于3.chat文件夹中.但是,当我运行以下命令时,它显示以下Warnings.And它没有在我的项目文件夹中创建一个node_modules目录.如何解决这个问题?
C:\Users\Nuwanst\Documents\NodeJS\3.chat>npm install socket.io
C:\Users\Nuwanst
`-- socket.io@2.0.3
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json'
npm WARN Nuwanst No description
npm WARN Nuwanst No repository field.
npm WARN Nuwanst No README data
npm WARN Nuwanst No license field.
Run Code Online (Sandbox Code Playgroud) 我最近将我的nodejs版本更新为10.30.0.一切正常.但我的gulp构建任务不起作用,在旧版本(9.X)上工作正常.这就是我得到的.
gulp[11376]: src\node_contextify.cc:629: Assertion `args[1]->IsString()' failed.
1: node::DecodeWrite
2: node::DecodeWrite
3: uv_loop_fork
4: v8::internal::interpreter::BytecodeDecoder::Decode
5: v8::internal::RegExpImpl::Exec
6: v8::internal::RegExpImpl::Exec
7: v8::internal::RegExpImpl::Exec
8: 00000384E1284281
Run Code Online (Sandbox Code Playgroud)
有人,请帮帮我.
目前,我在自己的文件中有4个子类.我要求他们都在同一个文件中.我想知道我是否可以在一个模块中包含所有这四个类.目前,我正在这样导入它们
var Jack = require('./Jack.js');
var JackInstance = new Jack();
var Jones = require('./Jones.js');
var JonesInstance = new Jones();
Run Code Online (Sandbox Code Playgroud)
我想像这样导入它们
var People = require('./People.js');
var JackInstance = new People.Jack();
Run Code Online (Sandbox Code Playgroud)
甚至
var Jack = require('./People.js').Jack;
var JackInstance = new Jack();
Run Code Online (Sandbox Code Playgroud)
我的课程定义如此
class Jack{
//Memeber variables, functions, etc
}
module.exports = Jack;
Run Code Online (Sandbox Code Playgroud) node-modules ×10
node.js ×7
javascript ×5
npm ×3
docker ×2
gulp ×1
ignore ×1
parcel ×1
regex ×1
sass ×1
server ×1
shell ×1
typescript ×1
vue.js ×1
webpack ×1